Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Me too tried to implement TTS in my application, i tried to implement it with some SDK but i cant. Now i am using <strong>GOOGLE TRANSLATE API</strong> ["<a href="http://www.translate.google.com/translate_tts?tl=en&amp;q=%@" rel="nofollow">http://www.translate.google.com/translate_tts?tl=en&amp;q=%@</a>",text"]. that will covert your text and give you a audio file you need to run the audio file after you stored it in Document directory [or customize as you like]. Just use this code. Hope it will help. </p> <pre><code>//Conversion using Google TTS API NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"file.mp3"]; NSString *text = textToConvert.text; NSString *urlString = [NSString stringWithFormat:@"http://www.translate.google.com/translate_tts?tl=en&amp;q=%@",text]; NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1" forHTTPHeaderField:@"User-Agent"]; NSURLResponse* response = nil; NSError* error = nil; NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error]; [data writeToFile:path atomically:YES]; NSError *err; if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { // player = [[AVAudioPlayer alloc] initWithContentsOfURL: // [NSURL fileURLWithPath:path] error:&amp;err]; //// player.volume = 0.4f; // [player prepareToPlay]; //// [player setNumberOfLoops:0]; // [player play]; player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&amp;err]; // player.delegate = self; [player prepareToPlay]; [player play]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload