语音转文字 API

Vivox 使用以下语音转文字转录方法。

启用或禁用转录

IVivoxService.SpeechToTextEnableTranscription

await VivoxService.Instance.SpeechToTextEnableTranscription( _channelName);

使用此方法在频道内启用语音转文字音频转录功能。此方法采用以下参数

ChannelName: 启用转录的频道名称。

IVivoxService.SpeechToTextDisableTranscription

await VivoxService.Instance.SpeechToTextDisableTranscription( _channelName);

使用此方法在频道内禁用语音转文字音频转录功能。此方法采用以下参数

ChannelName: 禁用转录的频道名称。

IVivoxService.IsSpeechToTextEnabled

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

使用此方法检查频道内是否启用了转录。此方法采用以下参数

ChannelName: 要检查是否已启用转录的频道名称。

转录通知

IVivoxService.SpeechToTextMessageReceived

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.
}

将此事件处理程序绑定/解除绑定到方法,以在添加转录消息时接收通知。

设置转录语言

LoginOptions.SpeechToTextLanguages

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

用作音频转录提示的语言列表。默认值为空数组,这意味着 en。您可以按优先级指定最多三种口语,以告知所有转录频道的用户的转录。IETF 语言标签字符串不会被验证,但应符合 BCP47(RFC 编辑器)。