Esempio n. 1
0
    private IEnumerator WaitForAudioFinishedCallback(float time, TextToSpeech.AudioFinishedCallback followupCallback)
    {
        yield return(new WaitForSeconds(time));

        _voiceProcessor.Active = true;
        if (followupCallback != null)
        {
            followupCallback();
        }
    }
Esempio n. 2
0
 private IEnumerator StartTextSynthesis(string text, TextToSpeech.AudioFinishedCallback followupCallback)
 {
     Log.Debug("ScriptReader", "Attempting synthesize");
     _voiceProcessor.Active = false;
     _textToSpeech.Voice    = VoiceType.en_US_Michael; //VoiceType.en_US_Allison;
     _textToSpeech.ToSpeech(text, HandleToSpeechCallback, true, null, followupCallback);
     while (!_synthesizeTested)
     {
         yield return(null);
     }
 }
Esempio n. 3
0
    private void PlayClip(AudioClip clip, TextToSpeech.AudioFinishedCallback followupCallback)
    {
        if (Application.isPlaying && clip != null)
        {
            GameObject  audioObject = new GameObject("AudioObject");
            AudioSource source      = audioObject.AddComponent <AudioSource>();
            source.spatialBlend = 0.0f;
            source.loop         = false;
            source.clip         = clip;
            source.Play();

            Destroy(audioObject, clip.length);
            StartCoroutine(WaitForAudioFinishedCallback(clip.length, followupCallback));

            _synthesizeTested = true;
        }
    }
Esempio n. 4
0
 public void ReadText(string text, TextToSpeech.AudioFinishedCallback followupCallback)
 {
     StartCoroutine(StartTextSynthesis(text, followupCallback));
 }
Esempio n. 5
0
 void HandleToSpeechCallback(AudioClip clip, string customData, TextToSpeech.AudioFinishedCallback followupCallback)
 {
     PlayClip(clip, followupCallback);
 }