Ejemplo n.º 1
0
    IEnumerator GetText(string value)
    {
        string origianlValue = value;

        value = url_01 + value + url_02;
        Debug.Log(value);
        value.Replace(" ", "%20");
        using (UnityWebRequest www = UnityWebRequest.Get(value))
        {
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
            }
            else
            {
                // Show results as text
                Debug.Log(www.downloadHandler.text);
                Regex  rgx             = new Regex(pattern);
                string translated_word = rgx.Match(www.downloadHandler.text).ToString();
                Debug.Log(translated_word);
                translated_word = translated_word.Substring(18, translated_word.Length - 19);
                Debug.Log(translated_word);
                t2S.text_content = translated_word;
                t2S.GetSound(origianlValue);
            }
        }
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        TextToSpeech script = (TextToSpeech)target;

        if (GUILayout.Button("PlaySound"))
        {
            script.PlaySound();
        }
        if (GUILayout.Button("GetSound"))
        {
            script.GetSound();
        }
    }