Search code examples
c#.nettext-to-speechozeki

Loop TextToSpeech message in Ozeki VOIP


Im using Microsoft Speech Platform with Ozeki VOIP Sip Client for playing TextToSpeech messages when I am calling SIP calls. How can I set TTS to loop the message forever in Ozeki?

I'm using this nuget package for Ozeki: http://www.nuget.org/packages/ozeki.voip.sip.client/

Here is my code:

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);

Solution

  • The answer was to attach the "stopped" event handler and play the text again to create a loop of the message.