Пример #1
0
    private void GetConfiguration()
    {
        SpeachToTextCommand command = new SpeachToTextCommand
        {
            action = "getVoicesList"
        };

        StartCoroutine(SendCommand(command, (body) => {
            SpeachToTextOfflineConfiguration conf = JsonUtility.FromJson <SpeachToTextOfflineConfiguration>(body);
            ListOfVoice.Clear();
            ListOfVoice.AddRange(conf.voices);
            string log = "";
            foreach (Voices s in ListOfVoice)
            {
                log += "Available " + s.name + " as a voice, ";
            }
            MagicRoomManager.instance.Logger.AddToLogNewLine("ServerTTSO", log);
        }));
    }
    IEnumerator getConfigurationFromServer()
    {
        command        = new SpeachToTextOfflineCommand();
        command.action = "getVoicesList";
        string json = JsonUtility.ToJson(command);

        print(json);
        byte[]          myData = System.Text.Encoding.UTF8.GetBytes(json);
        UnityWebRequest www    = UnityWebRequest.Put(address, myData);

        //UnityWebRequest www = UnityWebRequest.Post(address, json);
        www.SetRequestHeader("Content-Type", "application/json");
        yield return(www.Send());

        if (www.isNetworkError)
        {
            if (www.error == "Cannot connect to destination host")
            {
                MagicRoomSpeachToText_active = false;
            }
        }
        else
        {
            MagicRoomSpeachToText_active = true;
            Debug.Log(www.downloadHandler.text);
            SpeachToTextOfflineConfiguration conf = new SpeachToTextOfflineConfiguration();
            conf = JsonUtility.FromJson <SpeachToTextOfflineConfiguration>(www.downloadHandler.text);
            listofAssociatedNames = conf.voices;
            string log = "";
            foreach (VoicesOffline s in listofAssociatedNames)
            {
                log += "Available " + s.name + " as a voice, ";
            }
            Logger.addToLogNewLine("ServerTTSO", log);
        }
    }