示例#1
0
 public void SpeechPlayback()
 {
     if (speech.isReady)
     {
         string msg = input.text;
         speech.voiceName  = (VoiceName)voicelist.value;
         speech.VoicePitch = int.Parse(pitch.text);
         if (useSDK.isOn)
         {
             speech.SpeakWithSDKPlugin(msg);
         }
         else
         {
             speech.SpeakWithRESTAPI(msg);
         }
     }
     else
     {
         Debug.Log("SpeechManager is not ready. Wait until authentication has completed.");
     }
 }
示例#2
0
 /// <summary>
 /// Speech synthesis can be called via REST API or Speech Service SDK plugin for Unity
 /// </summary>
 public async void SpeechPlayback()
 {
     if (speech.isReady)
     {
         string msg = input.text;
         speech.voiceName  = (VoiceName)voicelist.value;
         speech.VoicePitch = int.Parse(pitch.text);
         if (useSDK.isOn)
         {
             // Required to insure non-blocking code in the main Unity UI thread.
             await Task.Run(() => speech.SpeakWithSDKPlugin(msg));
         }
         else
         {
             // This code is non-blocking by default, no need to run in background
             speech.SpeakWithRESTAPI(msg);
         }
     }
     else
     {
         Debug.Log("SpeechManager is not ready. Wait until authentication has completed.");
     }
 }