# 音声認識 API

> Use the speech-to-text API to transcribe voice messages.

Vivox では、以下の音声認識トランスクリプションメソッドが使用されます。

## トランスクリプションを有効または無効にする##enable-or-disable-transcription

### `IVivoxService.SpeechToTextEnableTranscription`##ivivoxservice.speechtotextenabletranscription

```cs
await VivoxService.Instance.SpeechToTextEnableTranscription( _channelName);
```

このメソッドを使用して、チャンネル内で音声認識トランスクリプション機能を有効にします。このメソッドは、以下のパラメーターを受け取ります。

`ChannelName`: トランスクリプションを有効にするチャンネルの名前。

### `IVivoxService.SpeechToTextDisableTranscription`##ivivoxservice.speechtotextdisabletranscription

```cs
await VivoxService.Instance.SpeechToTextDisableTranscription( _channelName);
```

このメソッドを使用して、チャンネル内で音声認識トランスクリプション機能を無効にします。このメソッドは、以下のパラメーターを受け取ります。

`ChannelName`: トランスクリプションを無効にするチャンネルの名前。

### `IVivoxService.IsSpeechToTextEnabled`##ivivoxservice.isspeechtotextenabled

```cs
bool isSpeechToTextEnabled = VivoxService.Instance.IsSpeechToTextEnabled(_channelName);
```

このメソッドを使用して、チャンネル内でのトランスクリプションが有効か無効かを確認します。このメソッドは、以下のパラメーターを受け取ります。

`ChannelName`: トランスクリプションが有効かどうかを確認するチャンネルの名前。

## トランスクリプション通知##transcription-notification

### `IVivoxService.SpeechToTextMessageReceived`##ivivoxservice.speechtotextmessagereceived

```cs
VivoxService.Instance.SpeechToTextMessageReceived += OnSpeechTotextMessageAdded;

VivoxService.Instance.SpeechToTextMessageReceived -= OnSpeechTotextMessageAdded;

private void OnSpeechTotextMessageReceived(VivoxMessage message)
{
    // Add your code here. “message” is the new transcribed message
    // added to the queue.
}
```

トランスクライブされたメッセージの追加時に通知を受け取るかどうかを設定するには、このイベントハンドラーをメソッドにバインド/バインド解除します。

## トランスクリプション言語を設定する##set-transcription-languages

### `LoginOptions.SpeechToTextLanguages`##loginoptions.speechtotextlanguages

```cs
loginOptions = loginOptions ?? new LoginOptions();
loginOptions.SpeechToTextLanguages = new List<string>{"en", "es", "fr"};
```

オーディオトランスクリプションのヒントとして使用されるオプションの言語のリスト。デフォルト値は空の配列で、`en` を示します。トランスクライブされるチャンネル内のすべてのユーザーのトランスクリプションを通知するための最大 3 つの音声言語を、希望する順に指定できます。IETF 言語タグの文字列は検証されませんが、[BCP47](https://tools.ietf.org/html/bcp47) に準拠する必要があります (RFC エディター)。
