コード例 #1
0
    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);
            }
        }
            );
    }
コード例 #2
0
    public void SpeakUsingAvailableLocaleOnDevice()
    {
        //on this example we will use spain locale
        TTSLocaleCountry ttsLocaleCountry = TTSLocaleCountry.SPAIN;

        //check if available
        bool isLanguageAvailanble = textToSpeechPlugin.CheckLocale(ttsLocaleCountry);

        if (isLanguageAvailanble)
        {
            string countryISO2Alpha = textToSpeechPlugin.GetCountryISO2Alpha(ttsLocaleCountry);

            //set spain language
            textToSpeechPlugin.SetLocaleByCountry(countryISO2Alpha);
            Debug.Log(TAG + "locale set," + ttsLocaleCountry.ToString() + "locale is available");

            SpeakOut();
        }
        else
        {
            Debug.Log(TAG + "locale not set," + ttsLocaleCountry.ToString() + "locale is  notavailable");
        }
    }