public void generateAudioFromText(string text, VoicesOffline voice) { if (!MagicRoomSpeachToText_active) { return; } command = new SpeachToTextOfflineCommand(); command.action = "speechSynthesis"; command.activityAddress = HttpListenerForMagiKRoom.instance.address + ":" + HttpListenerForMagiKRoom.instance.port + "/" + receivigCodeExpression; command.text = text; command.voice = voice.name; isPlaying = true; Logger.addToLogNewLine("ServerTTSO", text + "," + voice.name + " started"); StartCoroutine(sendCommand()); }
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); } }