- Home /
Text to speech using google API issue related to black space.
I have implemented Text to speech using google API . The issue i am facing is that the API cannot read the black space . For ex: It will say open instead of open the door. It do not read the space. Do help ???
here is my code:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System.Text.RegularExpressions;
public class TexttoSpeech : MonoBehaviour {
public AudioSource _audio;
// Use this for initialization
void Start () {
_audio = gameObject.GetComponent<AudioSource> ();
}
// Update is called once per frame
void Update () {
}
IEnumerator DownloadTheAudio(){
string url="http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=open the door&tl=En-gb";
WWW www = new WWW (url);
yield return www;
_audio.clip = www.GetAudioClip (false, true, AudioType.MPEG);
_audio.Play ();
}
public void ButtonClick(){
StartCoroutine (DownloadTheAudio ());
}
}
Thanks in advance.
Answer by Madhur26 · Jun 27, 2017 at 12:53 PM
Okay, I found the solution myself after much struggle. I just replaced white spaces in the sentence with "%20" and it worked.
Hope this will help someone.
Your answer
Follow this Question
Related Questions
How can I avoid distorted UI Text in Unity 5? 1 Answer
Text only seen in the Inspector 2 Answers
Display Hit Text On Collition 1 Answer
How to shrink text size 1 Answer
Best way to show image with text next to image target in Unity 0 Answers