Пример #1
0
    private void OnInit(int status)
    {
        dispatcher.InvokeAction(
            () => {
            Debug.Log(TAG + "OnInit status: " + status);

            if (status == 1)
            {
                UpdateStatus("init speech service successful!");

                //get available locale on android device
                //textToSpeechPlugin.GetAvailableLocale();

                //set default locale
                textToSpeechPlugin.SetLocale(SpeechLocale.US);
                UpdatePitch(1f);
                UpdateSpeechRate(1f);

                CancelInvoke("WaitingMode");
                Invoke("WaitingMode", waitingInterval);
            }
            else
            {
                UpdateStatus("init speech service failed!");

                CancelInvoke("WaitingMode");
                Invoke("WaitingMode", waitingInterval);
            }
        }
            );
    }
Пример #2
0
 private void UpdateLocale(SpeechLocale locale)
 {
     if (localeText != null)
     {
         localeText.text = String.Format("Locale: {0}", locale);
         textToSpeechPlugin.SetLocale(locale);
     }
 }
Пример #3
0
    private void OnInit(int status)
    {
        Debug.Log("[SpeechRecognizerDemo] OnInit status: " + status);

        if (status == 1)
        {
            hasInit = true;
            textToSpeechPlugin.SetLocale(SpeechLocale.US);
        }
    }
Пример #4
0
    //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);
        }
            );
    }
    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
    }