コード例 #1
0
    private void Start()
    {
        _gcTextToSpeech = GCTextToSpeech.Instance;

        _gcTextToSpeech.GetVoicesSuccessEvent  += _gcTextToSpeech_GetVoicesSuccessEvent;
        _gcTextToSpeech.SynthesizeSuccessEvent += _gcTextToSpeech_SynthesizeSuccessEvent;

        _gcTextToSpeech.GetVoicesFailedEvent  += _gcTextToSpeech_GetVoicesFailedEvent;
        _gcTextToSpeech.SynthesizeFailedEvent += _gcTextToSpeech_SynthesizeFailedEvent;

        _provider = (CultureInfo)CultureInfo.InvariantCulture.Clone();
        _provider.NumberFormat.NumberDecimalSeparator = ".";

        languageCodesList.Clear();
        VoiceModesList.Clear();
        VoicesList.Clear();
        for (int i = 0; i < Enum.GetNames(typeof(Enumerators.LanguageCode)).Length; i++)
        {
            languageCodesList.Add(((Enumerators.LanguageCode)i).ToString());
        }

        VoiceModesList.Clear();
        for (int i = 0; i < Enum.GetNames(typeof(Enumerators.VoiceType)).Length; i++)
        {
            VoiceModesList.Add(((Enumerators.VoiceType)i).ToString());
        }
        GetVoicesButtonOnClickHandler();
    }
コード例 #2
0
        // Start is called before the first frame update
        void Start()
        {
            _gcTextToSpeech = GCTextToSpeech.Instance;

            _gcTextToSpeech.GetVoicesSuccessEvent  += _gcTextToSpeech_GetVoicesSuccessEvent;
            _gcTextToSpeech.SynthesizeSuccessEvent += _gcTextToSpeech_SynthesizeSuccessEvent;

            _gcTextToSpeech.GetVoicesFailedEvent  += _gcTextToSpeech_GetVoicesFailedEvent;
            _gcTextToSpeech.SynthesizeFailedEvent += _gcTextToSpeech_SynthesizeFailedEvent;
            GetVoicesHandler();
        }
コード例 #3
0
    // Start is called before the first frame update
    void Start()
    {
        // Create a new Google cloud instance
        _gcTextToSpeech = GCTextToSpeech.Instance;

        // Add success and failure event methods to the current instance
        _gcTextToSpeech.SynthesizeSuccessEvent += _gcTextToSpeech_SynthesizeSuccessEvent;
        _gcTextToSpeech.SynthesizeFailedEvent  += _gcTextToSpeech_SynthesizeFailedEvent;

        // Add the culture info and number format to the provider
        _provider = (CultureInfo)CultureInfo.InvariantCulture.Clone();
        _provider.NumberFormat.NumberDecimalSeparator = ".";

        // Add the chosen voice configuration to _currentVoice
        String[] myTypes = { Enumerators.LanguageCode.en_US.ToString() };
        _currentVoice.languageCodes          = myTypes;
        _currentVoice.name                   = "en-US-Wavenet-A";
        _currentVoice.naturalSampleRateHertz = 24000.0;
        _currentVoice.ssmlGender             = Enumerators.SsmlVoiceGender.MALE;

        using (StreamWriter responsesOutput = new StreamWriter(@"Assets/OutputData/responsesLog" + simulationStart + ".txt", true))
        {
            responsesOutput.WriteLine("--- Log of Keywords and responses in current simulation ---\n");
        }

        //Create instance of myAssistanceBot
        assistanceBot myAssistanceBot = new assistanceBot();

        //Create BotConfig which is object containing new dictionary with key-responses from input JSON file
        BotConfig assistanceBotJSON = myAssistanceBot.ConfParser();

        // Defining a list of keys to iterate over
        List <string> keys = new List <string>(assistanceBotJSON.keywordDict.Keys);

        // loop over each key in the responses dictionary
        foreach (string key in keys)
        {
            // add each key and response to the phrases dictionary
            string response = assistanceBotJSON.keywordDict[key];

            phrases.Add(key, () => { speakResponse(response); });
        }

        // initialize a new keyword recognizer and populate with phrases
        keywordRecognizer = new KeywordRecognizer(phrases.Keys.ToArray());
        keywordRecognizer.OnPhraseRecognized += phraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #4
0
    void InitAudio()
    {
        // Initilize Text2Voice & Voice
        MC = GCTextToSpeech.Instance;
        MC.SynthesizeSuccessEvent += _gcTextToSpeech_SynthesizeSuccessEvent;
        MC.SynthesizeFailedEvent  += _gcTextToSpeech_SynthesizeFailedEvent;
        switch (PlayerPrefs.GetString("voice"))
        {
        case "English":
            myvoice.languageCode = "en-US";
            myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
            myvoice.name         = "en-US-Wavenet-E";
            break;

        case "Español":
            myvoice.languageCode = "es-ES";
            myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
            myvoice.name         = "es-ES-Standard-A";
            break;

        case "Français":
            myvoice.languageCode = "fr-FR";
            myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
            myvoice.name         = "fr-FR-Wavenet-E";
            break;

        case "Portuguese":
            myvoice.languageCode = "pt-BR";
            myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
            myvoice.name         = "pt-BR-Wavenet-A";
            break;

        case "Italiano":
            myvoice.languageCode = "it-IT";
            myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
            myvoice.name         = "it-IT-Wavenet-B";
            break;

        default:
            PlayerPrefs.SetString("voice", "English");
            myvoice.languageCode = "en-US";
            myvoice.gender       = Enumerators.SsmlVoiceGender.FEMALE;
            myvoice.name         = "en-US-Wavenet-E";
            break;
        }
    }