void Update() { if (Input.GetKeyDown(KeyCode.Return)) { service.SynthesizeUsingWebsockets(textInput.text); textInput.text = waitingText; } while (service != null && !service.IsListening) { if (audioStream != null && audioStream.Length > 0) { Log.Debug("ExampleTextToSpeech", "Audio stream of {0} bytes received!", audioStream.Length.ToString()); // Use audioStream and play audio _recording = WaveFile.ParseWAV("myClip", audioStream); PlayClip(_recording); } textInput.text = placeholderText; audioStream = null; StartListening(); // need to connect because service disconnect websocket after transcribing https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-usingWebSocket#WSsend } }
public void TextToSpeech(string text) { service.SynthesizeUsingWebsockets(text); }
public void loadText(string text) { audioStream = null; StartListening(); service.SynthesizeUsingWebsockets(text); }