在 Ozeki VOIP 中循环 TextToSpeech 消息

Loop TextToSpeech message in Ozeki VOIP

我正在使用带有 Ozeki VOIP Sip 客户端的 Microsoft Speech Platform 在呼叫 SIP 呼叫时播放 TextToSpeech 消息。如何设置 TTS 在 Ozeki 中永远循环播放消息?

我正在为 Ozeki 使用这个 nuget 包:http://www.nuget.org/packages/ozeki.voip.sip.client/

这是我的代码:

var textToSpeech = new TextToSpeech();

var msp = new MSSpeechPlatformTTS();

textToSpeech.AddTTSEngine(msp);

var clientLanguage = ConfigurationManager.AppSettings["TextSpeechLanguage"];

var voices = textToSpeech.GetAvailableVoices();

foreach (var voice in voices)
{
    if (voice.Language == clientLanguage)
        textToSpeech.ChangeLanguage(voice.Language, voice.Name);
}

if (string.IsNullOrEmpty(speechString))
{
    textToSpeech.ChangeLanguage("en-GB");
    speechString = "You have a visitor. Press 1 to accept the visit. Press 2 to talk the the visitor.";
}  

mediaSender.AttachToCall(call);
connector.Connect(textToSpeech, mediaSender);

textToSpeech.AddAndStartText(speechString);

我认为它可以帮助你。尝试相应地更改代码的最后一行:

while(true)
{
textToSpeech.AddAndStartText(speechString);
}

您可以详细了解如何使用 MS Speach Platform 11 in C# here

答案是附加 "stopped" 事件处理程序并再次播放文本以创建消息循环。