示例#1
0
        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
            }
        }
示例#2
0
 public void TextToSpeech(string text)
 {
     service.SynthesizeUsingWebsockets(text);
 }
示例#3
0
 public void loadText(string text)
 {
     audioStream = null;
     StartListening();
     service.SynthesizeUsingWebsockets(text);
 }