private void OnInit(int status) { dispatcher.InvokeAction( () => { if (status == 1) { Debug.Log("init speech service successful!"); //get available locale on android device //textToSpeechPlugin.GetAvailableLocale(); //set default locale textToSpeechPlugin.SetLocaleByCountry(textToSpeechPlugin.GetCountryISO2Alpha(TTSLocaleCountry.PORTUGAL)); textToSpeechPlugin.SetPitch(1f); textToSpeechPlugin.SetSpeechRate(1f); CancelInvoke("WaitingMode"); Invoke("WaitingMode", waitingInterval); } else { Debug.Log("init speech service failed!"); CancelInvoke("WaitingMode"); Invoke("WaitingMode", waitingInterval); } } ); }
private void UpdatePitch(float pitch) { if (pitchText != null) { pitchText.text = String.Format("Pitch: {0}", pitch); textToSpeechPlugin.SetPitch(pitch); } }
private void OnSetLocale(int status) { Debug.Log("[SpeechRecognizerDemo] OnSetLocale status: " + status); if (status == 1) { textToSpeechPlugin.SetPitch(1f); } }
void Start() { #if UNITY_ANDROID if (Application.platform != RuntimePlatform.Android) { return; } textToSpeechPlugin.SetLocale(SpeechLocale.UK); if (Speech_Pitch_Slider != null && Speech_Rate_Slider != null && Speech_Volume_Slider != null) { all_control_slider_is_assigned = true; Speech_Pitch_Slider.maxValue = 2; Speech_Pitch_Slider.minValue = 0.1f; Speech_Pitch_Slider.value = Speech_Pitch; Speech_Rate_Slider.maxValue = 2; Speech_Rate_Slider.minValue = 0.1f; Speech_Rate_Slider.value = Speech_Rate; Speech_Volume_Slider.maxValue = 15; Speech_Volume_Slider.minValue = 0; Mathf.Clamp(Speech_Volume, 0, 15); Speech_Volume_Slider.value = Speech_Volume; } else { textToSpeechPlugin.SetPitch(Speech_Pitch); textToSpeechPlugin.SetSpeechRate(Speech_Rate); Mathf.Clamp(Speech_Volume, 0, 15); utilsPlugin.IncreaseMusicVolumeByValue(Speech_Volume); // 0 to 15, max 15 } #endif }
//SpeechRecognizer Events //TextToSpeechPlugin Events private void OnInit(int status) { dispatcher.InvokeAction( () => { if (status == 1) { textToSpeechPlugin.SetLocale(SpeechLocale.US); textToSpeechPlugin.SetPitch(1f); textToSpeechPlugin.SetSpeechRate(1f); } else { utilsPlugin.ShowToastMessage("Error while initializing TTS!"); } CancelInvoke("WaitingMode"); Invoke("WaitingMode", waitingInterval); } ); }