Example #1
0
        public void Synthesize()
        {
            IamConfig config = new IamConfig(
                apikey: apikey
                );

            TextToSpeechService service = new TextToSpeechService(config);

            service.SetEndpoint(url);

            var result = service.Synthesize(
                text: "Hello, welcome to the Watson dotnet SDK!",
                accept: "audio/wav",
                voice: "en-US_AllisonVoice"
                );

            //  Save file
            using (FileStream fs = File.Create("synthesize.wav"))
            {
                result.Result.WriteTo(fs);
                fs.Close();
                result.Result.Close();
            }

            Console.WriteLine(result.Result);
        }
Example #2
0
        public void Synthesize_Success()
        {
            IClient  client  = Substitute.For <IClient>();
            IRequest request = Substitute.For <IRequest>();

            client.PostAsync(Arg.Any <string>())
            .Returns(request);

            TextToSpeechService service = new TextToSpeechService(client);

            var text            = "text";
            var accept          = "accept";
            var voice           = "voice";
            var customizationId = "customizationId";

            var result = service.Synthesize(text: text, accept: accept, voice: voice, customizationId: customizationId);

            JObject bodyObject = new JObject();

            if (!string.IsNullOrEmpty(text))
            {
                bodyObject["text"] = JToken.FromObject(text);
            }
            var json = JsonConvert.SerializeObject(bodyObject);

            request.Received().WithBodyContent(Arg.Is <StringContent>(x => x.ReadAsStringAsync().Result.Equals(json)));
        }
Example #3
0
        private IEnumerator ExampleSynthesize()
        {
            byte[]    synthesizeResponse = null;
            AudioClip clip = null;

            service.Synthesize(
                callback: (DetailedResponse <byte[]> response, IBMError error) =>
            {
                synthesizeResponse = response.Result;
                Log.Debug("ExampleTextToSpeechV1", "Synthesize done!");
                clip = WaveFile.ParseWAV("myClip", synthesizeResponse);
                PlayClip(clip);
            },
                text: synthesizeText,
                voice: allisionVoice,
                accept: synthesizeMimeType
                );

            while (synthesizeResponse == null)
            {
                yield return(null);
            }

            yield return(new WaitForSeconds(clip.length));
        }
Example #4
0
        private IEnumerator ExampleSynthesize(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                text = synthesizeText;
                Log.Debug("ExampleTextToSpeechV1", "Using default text, please enter your own text in dialog box!");
            }
            byte[]    synthesizeResponse = null;
            AudioClip clip = null;

            service.Synthesize(
                callback: (DetailedResponse <byte[]> response, IBMError error) =>
            {
                synthesizeResponse = response.Result;
                Log.Debug("ExampleTextToSpeechV1", "Synthesize done!");
                clip = WaveFile.ParseWAV("myClip", synthesizeResponse);
                PlayClip(clip);
            },
                text: text,
                voice: allisionVoice,
                accept: synthesizeMimeType
                );

            while (synthesizeResponse == null)
            {
                yield return(null);
            }

            yield return(new WaitForSeconds(clip.length));
        }
Example #5
0
        public JsonResult ProcesarWatsonTTS(String texto)
        {
            object result = null;

            try
            {
                TextToSpeechService text_to_speech = new TextToSpeechService(Auth.Watson_TTS.Username, Auth.Watson_TTS.Password);
                var results    = text_to_speech.Synthesize(texto, Voice.ES_SOFIA, AudioType.WAV);
                var fileStream = new FileStream("resources/audioTTS.wav", FileMode.Create, FileAccess.Write);
                results.CopyTo(fileStream);
                fileStream.Dispose();

                result = new {
                    data   = "tts.wav",
                    status = "Ok"
                };
            }
            catch (Exception ex)
            {
                result = new {
                    data   = ex.Message,
                    status = "Error"
                };
            }

            return(Json(result));
        }
Example #6
0
        public void Synthesize()
        {
            TokenOptions tokenOptions = new TokenOptions()
            {
                IamApiKey  = apikey,
                ServiceUrl = url
            };

            TextToSpeechService service = new TextToSpeechService(tokenOptions);

            var result = service.Synthesize(
                text: "Hello, welcome to the Watson dotnet SDK!",
                accept: "audio/wav",
                voice: "en-US_AllisonVoice"
                );

            //  Save file
            using (FileStream fs = File.Create("synthesize.wav"))
            {
                result.Result.WriteTo(fs);
                fs.Close();
                result.Result.Close();
            }

            Console.WriteLine(result.Result);
        }
Example #7
0
        public IEnumerator MyCoroutine()
        {
            string text = Text.text;

            while (!authenticator.CanAuthenticate())
            {
                yield return(null);
            }

            textToSpeechService = new TextToSpeechService(authenticator);
            textToSpeechService.SetServiceUrl("https://gateway-lon.watsonplatform.net/text-to-speech/api");

            byte[]    synthesizeResponse = null;
            AudioClip clip = null;

            textToSpeechService.Synthesize(
                callback: (DetailedResponse <byte[]> response, IBMError error) =>
            {
                synthesizeResponse = response.Result;
                clip = WaveFile.ParseWAV("hello_world.wav", synthesizeResponse);
                AudioSource audioSource = GetComponent <AudioSource>();
                audioSource.clip        = clip;
                audioSource.Play();
            },
                text: text,
                voice: voice,
                accept: "audio/wav"
                );

            while (synthesizeResponse == null)
            {
                yield return(null);
            }
        }
        private async void FalarMensagem()
        {
            //Rd6JgXi2SiivDo02qoGlf2fzh88qf71rNhOVEhuPrzQG

            string           texto         = "Seja bem-vindo";
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "Rd6JgXi2SiivDo02qoGlf2fzh88qf71rNhOVEhuPrzQG");

            TextToSpeechService service = new TextToSpeechService(authenticator);

            service.SetServiceUrl("https://stream.watsonplatform.net/text-to-speech/api");

            var result = service.Synthesize(
                text: texto,
                accept: "audio/wav",
                voice: "pt-BR_IsabelaVoice"
                );

            using (FileStream fs = File.Create("nsf_texto_voz.wav"))//Cria um arquivo físico no meu HD
            {
                result.Result.WriteTo(fs);
                fs.Close();
                result.Result.Close();
            }

            AudioPlayer player = new AudioPlayer();
            await player.SetFileAsync("nsf_texto_voz.wav", "nsf_texto_voz.wav"); //Rodam ao mesmo tempo (as duas linhas)

            await player.PlayAsync();
        }
Example #9
0
//Synthesizes the sentence
    public void SynthesizeSentence(string sentence)
    {
        activeFile   = Regex.Replace(sentence, @"[^a-zA-Z0-9 -]", "").ToLower();
        activeFile   = Regex.Replace(activeFile, @"\s+", string.Empty);
        DialogueHash = activeFile;
        using (MD5 md5Hash = MD5.Create())
        {
            DialogueHash = GetMd5Hash(md5Hash, DialogueHash);
        }
        ttsSynthesing = true;
        if (voiceLines.ContainsKey(DialogueHash))
        {
            associatedSource.clip = WaveFile.ParseWAV(DialogueHash, voiceLines[DialogueHash]);
            ttsSynthesing         = false;
            //associatedSource.PlayOneShot(Resources.Load<AudioClip>("Sounds/" + fileNameSaveFile));
        }
        else
        {
            tts.Synthesize(OnSynthesize, sentence, "en-US_AllisonV3Voice", null, "audio/wav");
        }
        if (PlayerPrefs.HasKey(activeFile))
        {
            emotionScore = PlayerPrefs.GetFloat(activeFile);
        }
        else
        {
            ToneInput tempInput = new ToneInput();
            tempInput.Text = sentence;
            tas.Tone(OnToneAnalysis, tempInput, false, tones);
        }
    }
Example #10
0
    public override void TextToSpeech(string outputText)
    {
        Debug.Log("Send to TTS Watson: " + outputText);

        if (!string.IsNullOrEmpty(outputText))
        {
            byte[]    synthesizeResponse = null;
            AudioClip clip = null;

            _service.Synthesize(
                callback: (DetailedResponse <byte[]> response, IBMError error) =>
            {
                if (response != null && response.Result != null && response.Result.Length > 0)
                {
                    synthesizeResponse = response.Result;
                    clip = WaveFile.ParseWAV("answer", synthesizeResponse);
                    ManageOutput(clip, outputText);
                }
            },
                text: outputText,
                voice: "en-US_AllisonVoice",
                accept: "audio/wav"
                );
        }
    }
    public IEnumerator RunSynthesize()
    {
        Debug.Log("[" + name + "] Attempting to Synthesize...");
        byte []   synthesizeResponse = null;
        AudioClip clip = null;

        service.Synthesize(
            callback: (DetailedResponse <byte []> response, IBMError error) => {
            synthesizeResponse = response.Result;
            File.WriteAllBytes(audioPath, synthesizeResponse);
            clip = WaveFile.ParseWAV("voice_response", synthesizeResponse);
            LoadingParticles.Stop();
            audioSource.PlayOneShot(clip);
        },
            text: InputText,
            voice: allisionVoice,
            accept: synthesizeMimeType
            );
        while (synthesizeResponse == null)
        {
            yield return(null);
        }
        yield return(new WaitForSeconds(clip.length));

        ReadyToSend = true;
        SelectableUIElement.ChangeLock(-1);
    }
    private void CallTextToSpeech(string outputText)
    {
        Debug.Log("Sent to Watson Text To Speech: " + outputText);

        watsonAnswer.text = outputText;

        byte[]    synthesizeResponse = null;
        AudioClip clip = null;

        //NEW: added below if to prevent null text error from occuring in TextToSpeechService
        if (outputText != null)
        {
            _textToSpeech.Synthesize(
                callback: (DetailedResponse <byte[]> response, IBMError error) =>
            {
                synthesizeResponse = response.Result;
                clip = WaveFile.ParseWAV("myClip", synthesizeResponse);
                PlayClip(clip);
            },
                text: outputText,
                voice: "en-US_MichaelVoice",
                accept: "audio/wav"
                );
        }
    }
        public IEnumerator TestSynthesize()
        {
            Log.Debug("TextToSpeechServiceV1IntegrationTests", "Attempting to Synthesize...");
            byte[]    synthesizeResponse = null;
            AudioClip clip = null;

            service.Synthesize(
                callback: (DetailedResponse <byte[]> response, IBMError error) =>
            {
                synthesizeResponse = response.Result;
                Assert.IsNotNull(synthesizeResponse);
                Assert.IsNull(error);
                clip = WaveFile.ParseWAV("myClip", synthesizeResponse);
                PlayClip(clip);
            },
                text: synthesizeText,
                voice: allisionVoice,
                accept: synthesizeMimeType
                );

            while (synthesizeResponse == null)
            {
                yield return(null);
            }

            yield return(new WaitForSeconds(clip.length));
        }
Example #14
0
        public static IEnumerator Speech(string text)
        {
            Debug.Log("Me llaman para hablar");
            if (text != "")
            {
                byte[]    synthesizeResponse = null;
                AudioClip clip = null;
                tts.Synthesize(
                    callback: (DetailedResponse <byte[]> response, IBMError error) =>
                {
                    synthesizeResponse = response.Result;
                    Debug.Log("ExampleTextToSpeechV1");
                    clip = WaveFile.ParseWAV("myClip", synthesizeResponse);
                    PlayClip(clip);
                },
                    text: text,
                    voice: allisionVoice,
                    accept: synthesizeMimeType
                    );

                while (synthesizeResponse == null)
                {
                    yield return(null);
                }

                yield return(new WaitForSeconds(clip.length));
            }
            yield return(null);
        }
Example #15
0
        private static void Main(string[] args)
        {
            string credentials = string.Empty;

            #region Get Credentials
            string _endpoint = string.Empty;
            string _username = string.Empty;
            string _password = string.Empty;

            if (string.IsNullOrEmpty(credentials))
            {
                var    parentDirectory     = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.Parent.FullName;
                string credentialsFilepath = parentDirectory + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "credentials.json";
                if (File.Exists(credentialsFilepath))
                {
                    try
                    {
                        credentials = File.ReadAllText(credentialsFilepath);
                        credentials = Utility.AddTopLevelObjectToJson(credentials, "VCAP_SERVICES");
                    }
                    catch (Exception e)
                    {
                        throw new Exception(string.Format("Failed to load credentials: {0}", e.Message));
                    }

                    VcapCredentials vcapCredentials = JsonConvert.DeserializeObject <VcapCredentials>(credentials);
                    var             vcapServices    = JObject.Parse(credentials);

                    Credential credential = vcapCredentials.GetCredentialByname("text-to-speech-sdk")[0].Credentials;
                    _endpoint = credential.Url;
                    _username = credential.Username;
                    _password = credential.Password;
                }
                else
                {
                    Console.WriteLine("Credentials file does not exist. Please define credentials.");
                    _username = "";
                    _password = "";
                    _endpoint = "";
                }
            }
            #endregion

            string _synthesizeText = "Hello, welcome to the Watson dotnet SDK!";

            Text synthesizeText = new Text
            {
                _Text = _synthesizeText
            };

            var _service = new TextToSpeechService(_username, _password);
            _service.SetEndpoint(_endpoint);

            // MemoryStream Result with .wav data
            var synthesizeResult = _service.Synthesize(synthesizeText, "audio/wav");
            Console.ReadKey();
        }
    private IEnumerator ProcessText()
    {
        Debug.Log("ProcessText");

        string nextText = String.Empty;

        audioStatus = ProcessingStatus.Processing;

        if (outputAudioSource.isPlaying)
        {
            yield return(null);
        }

        if (textQueue.Count < 1)
        {
            yield return(null);
        }
        else
        {
            nextText = textQueue.Dequeue();
            Debug.Log(nextText);

            if (String.IsNullOrEmpty(nextText))
            {
                yield return(null);
            }
        }

        byte[]    synthesizeResponse = null;
        AudioClip clip = null;

        tts_service.Synthesize(
            callback: (DetailedResponse <byte[]> response, IBMError error) =>
        {
            synthesizeResponse = response.Result;
            clip = WaveFile.ParseWAV("myClip", synthesizeResponse);

            //Place the new clip into the audio queue.
            audioQueue.Enqueue(clip);
        },
            text: nextText,
            ////////////////////////////////////////
            //voice: "en-" + voice,
            voice: "ko-" + voice,
            accept: "audio/wav"
            );

        while (synthesizeResponse == null)
        {
            yield return(null);
        }

        // Set status to indicate text to speech processing task completed
        audioStatus = ProcessingStatus.Idle;
    }
    private IEnumerator ProcessText()
    {
        Debug.Log("ProcessText");
        _audioStatus = EProcessingStatus.Processing;

        if (_outputAudioSource.isPlaying)
        {
            yield return(null);
        }

        string nextText = String.Empty;

        if (textQueue.Count < 1)
        {
            yield return(null);
        }
        else
        {
            nextText = textQueue.Dequeue();
            Debug.Log(nextText);

            if (String.IsNullOrEmpty(nextText))
            {
                yield return(null);
            }
        }

        // The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers
        // Doc: https://cloud.ibm.com/apidocs/text-to-speech?code=unity#synthesize
        byte[]    synthesizeResponse = null;
        AudioClip clip = null;

        _textToSpeechService.Synthesize(
            callback: (DetailedResponse <byte[]> response, IBMError error) =>
        {
            synthesizeResponse = response.Result;
            clip = WaveFile.ParseWAV("message.wav", synthesizeResponse);

            //Place the new clip into the audio queue.
            audioQueue.Enqueue(clip);
        },
            text: nextText,
            voice: $"en-{voice}",
            accept: "audio/wav"
            );

        while (synthesizeResponse == null)
        {
            yield return(null);
        }

        // Set status to indicate text to speech processing task completed
        _audioStatus = EProcessingStatus.Idle;
    }
 public override void Say(string text)
 {
     text = SecurityElement.Escape(text);
     //text = "<voice-transformation type=\"Custom\" glottal_tension=\"+80%\" breathiness=\"-80%\" pitch=\"-100%\" pitch_range=\"-25%\">" + text;
     //text += "</voice-transformation>";
     print(text);
     if (!_textToSpeech.Synthesize(callback: OnSynthesize, text: text, voice: serviceVoice, accept: "audio/wav"))
     {
         Log.Debug("SpeechSynthesizer.Synthesize()", "Failed to synthesize!");
     }
 }
      public IEnumerator SynthesizeText(string textToRead, NarratorBehaviour output)
      {
          if (textToRead == null || textToRead == "")
          {
              textToRead = "Cagin Nicolas Cage in a cage. Yep c**k. Also this is a default message.";
          }
          byte[]    synthesizeResponse = null;
          AudioClip clip = null;

          if (tts != null && isLive)
          {
              tts.Synthesize(
                  callback: (DetailedResponse <byte[]> response, IBMError error) =>
                {
                    synthesizeResponse = response.Result;
                    clip = WaveFile.ParseWAV("Narrator_text.wav", synthesizeResponse);
                    Debug.Log("clip");
                    Debug.Log(clip);
                    if (error != null)
                    {
                        Debug.Log(error.ErrorMessage);
                    }
                },
                  text: textToRead,
                  voice: "en-US_MichaelVoice",
                  accept: "audio/wav"
                  );

              while (synthesizeResponse == null)
              {
                  yield return(null);
              }
              output.textToSpeechClip = clip;
          }
          else
          {
              Debug.LogWarning("Custom warning message: Narrator should have spoken, but TTS is null or just in developer mode to debug mock instead");
              Debug.LogWarning("Narrator is reading this: " + textToRead);
              yield return(null);
          }
      }
        private void Synthesize()
        {
            Console.WriteLine(string.Format("Calling Synthesize({0})...", _text));

            var results = _textToSpeech.Synthesize(_text, Voice.EN_ALLISON, AudioType.WAV);

            if (results != null)
            {
                Console.WriteLine(string.Format("Succeeded to synthesize {0} | stream length: {1}", _text, results.Length));
            }
            else
            {
                Console.WriteLine("Failed to synthesize.");
            }
        }
Example #21
0
        public static Stream Authenticate()
        {
            TextToSpeechService _textToSpeech = new TextToSpeechService();
            string username = "******";
            string password = "******";

            //string url = "https://stream.watsonplatform.net/text-to-speech/api";



            _textToSpeech.SetCredential(username, password);
            var voices = _textToSpeech.GetVoices();
            var strem  = _textToSpeech.Synthesize("Hello Sabio Nation! Go win some money!", Voice.EN_ALLISON, AudioType.WAV);

            return(strem);
        }
Example #22
0
        private System.IO.MemoryStream Synthesize(Text text, string accept = null, string voice = null, string customizationId = null, Dictionary <string, object> customData = null)
        {
            Console.WriteLine("\nAttempting to Synthesize()");
            var result = service.Synthesize(text: text, accept: accept, voice: voice, customizationId: customizationId, customData: customData);

            if (result != null)
            {
                Console.WriteLine("Synthesize() succeeded!");
            }
            else
            {
                Console.WriteLine("Failed to Synthesize()");
            }

            return(result);
        }
 public void Speak(string text)
 {
     Debug.Log("Sending to Watson to generate voice audio output: " + text);
     if (text != null && text != "")
     {
         myService.Synthesize(
             callback: onSynthCompleted,
             text: text,
             voice: myVoice,
             accept: "audio/wav"
             );
     }
     else
     {
         Debug.Log("WARNING: text to speech: text was empty");
     }
 }
Example #24
0
        public async Task <string> ToAudio(string transcript)
        {
            if (textToSpeechClient == null)
            {
                return("");
            }
            var BUFFER_SIZE    = 2048;
            var timeStamp      = DateTime.Now.ToString("MM-dd-yyyy_HH_mm_ss");
            var outputFileName = $@".\vocalized\{timeStamp}.mp3";
            var text           = new Text();

            text._Text = transcript;
            try
            {
                using (FileStream fileStream = new FileStream(outputFileName, FileMode.Create))
                {
                    var result = await Task.Run(() =>
                    {
                        return(textToSpeechClient.Synthesize(
                                   text: text,
                                   accept: "audio/mp3",
                                   voice: settingsService.settings.ibmSettings.Voice.Name
                                   ));
                    });

                    byte[] buffer = new byte[BUFFER_SIZE];
                    int    readBytes;

                    using (BufferedStream bufferedInput = new BufferedStream(result))
                    {
                        while ((readBytes = await bufferedInput.ReadAsync(buffer, 0, buffer.Length)) > 0)
                        {
                            await fileStream.WriteAsync(buffer, 0, readBytes);
                        }
                    }
                }
                return(outputFileName);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception caught: " + e);
                MessageBox.Show("Exception caught: " + e);
            }
            return(outputFileName);
        }
        public void Synthesize_Success()
        {
            service.WithHeader("X-Watson-Test", "1");
            var synthesizeResult = service.Synthesize(
                text: synthesizeText,
                accept: "audio/wav",
                voice: allisonVoice
                );

            //  Save file
            using (FileStream fs = File.Create("synthesize.wav"))
            {
                synthesizeResult.Result.WriteTo(fs);
                fs.Close();
                synthesizeResult.Result.Close();
            }

            Assert.IsNotNull(synthesizeResult.Result);
        }
Example #26
0
    private void CallTextToSpeech(string outputText)
    {
        Debug.Log("Sent to Watson Text To Speech: " + outputText);

        byte[]    synthesizeResponse = null;
        AudioClip clip = null;

        _textToSpeech.Synthesize(
            callback: (DetailedResponse <byte[]> response, IBMError error) =>
        {
            synthesizeResponse = response.Result;
            clip = WaveFile.ParseWAV("myClip", synthesizeResponse);
            PlayClip(clip);
        },
            text: outputText,
            voice: "en-US_AllisonVoice",
            accept: "audio/wav"
            );
    }
Example #27
0
        private void SynthesizeButton_Click(object sender, EventArgs e)
        {
            var fileIniDataParser = new FileIniDataParser();
            var iniData           = fileIniDataParser.ReadFile(this.iniFile);
            var tokenOptions      = new TokenOptions
            {
                IamApiKey  = iniData["TextToSpeechService"]["ApiKey"],
                ServiceUrl = iniData["TextToSpeechService"]["ServiceUrl"]
            };

            try
            {
                if (this.OutputFileTextBox.Tag is bool && false == (bool)this.OutputFileTextBox.Tag)
                {
                    //update the output file
                    this.OutputFileTextBox.Text = this.GetNewOutputFile();
                }

                var service = new TextToSpeechService(tokenOptions);
                var text    = new Text {
                    _Text = this.TextToSynthesizeTextBox.Text
                };

                using (var fileStream = File.Create(this.OutputFileTextBox.Text))
                {
                    using (var memoryStream = service.Synthesize(text, "audio/wav"))
                    {
                        memoryStream.CopyTo(fileStream);
                    }
                }

                if (this.TextToSynthesizeTextBox.Tag is bool && false == (bool)this.TextToSynthesizeTextBox.Tag)
                {
                    //randomize a new phrase
                    this.TextToSynthesizeTextBox.Text = this.GetNewPangram();
                }
            }
            catch (Exception ex)
            {
                this.Log(LogLevel.Error, ex);
            }
        }
Example #28
0
    private IEnumerator Synthesize(string synthesizeText, string voice)
    {
        Log.Debug("WatsonTTS", "Attempting to Synthesize...");
        byte[]    synthesizeResponse = null;
        AudioClip clip = null;

        // _service.Synthesize(
        //     callback: (DetailedResponse<byte[]> response, IBMError error) =>
        //     {
        //         synthesizeResponse = response.Result;
        //         Assert.IsNotNull(synthesizeResponse);
        //         Assert.IsNull(error);
        //         clip = WaveFile.ParseWAV("myClip", synthesizeResponse);
        //         PlayClip(clip);

        //     },
        //     text: synthesizeText,
        //     voice: voice,
        //     accept: synthesizeMimeType
        // );
        _service.Synthesize(
            callback: (DetailedResponse <byte[]> response, IBMError error) =>
        {
            synthesizeResponse = response.Result;
            Log.Debug("Watson TTS", "Synthesize done!");
            clip = WaveFile.ParseWAV("myClip", synthesizeResponse);
            StartCoroutine(PlayClip(clip));
        },
            text: synthesizeText,
            voice: voice,
            accept: synthesizeMimeType
            );

        while (synthesizeResponse == null)
        {
            yield return(null);
        }

        yield return(new WaitForSeconds(clip.length));

        m_callbackMethod(synthesizeText, clip.length);
    }
Example #29
0
    private void GetTTS()
    {
        //  Synthesize
        Log.Debug("WatsonTTS", "Attempting synthesize.");
        byte[]    synthesizeResponse = null;
        AudioClip clip = null;

        TTSService.Synthesize(
            callback: (DetailedResponse <byte[]> response, IBMError error) =>
        {
            synthesizeResponse = response.Result;
            clip  = WaveFile.ParseWAV("myClip", synthesizeResponse);
            wait  = clip.length;
            check = true;
            PlayClip(clip);
        },
            text: TTS_content,
            voice: allisionVoice,
            accept: synthesizeMimeType
            );
    }
Example #30
0
    public IEnumerator CallTextToSpeech(string outputText)
    {
        byte[]    synthesizeResponse = null;
        AudioClip clip = null;

        textToSpeech.Synthesize(
            callback: (DetailedResponse <byte[]> response, IBMError error) =>
        {
            synthesizeResponse = response.Result;
            clip = WaveFile.ParseWAV("myClip", synthesizeResponse);
            PlayClip(clip);
        },
            text: outputText,
            voice: "es-LA_SofiaVoice",
            accept: "audio/wav"
            );
        while (synthesizeResponse == null)
        {
            yield return(null);
        }
        yield return(new WaitForSeconds(clip.length));
    }