Friday, September 20, 2013

Text to Speech with iOS7 UIWebView

The WebKit with iOS 7.0+, and mobile safari now supports direct TTS Calls using SpeechSynthesis APIs. It's super cool because with relatively sparse code you can have your app talking to you in nearly 36 different voices, along with numerous pitch and rate modifications. Here below is a simple Method where you can pass in text String and have the app dictate it back to you (remember you need to be using iOS 7+ SDK):

- (void) speakThis: (NSString*) text {
        //speechSynthesis.speak(new SpeechSynthesisUtterance("%@"));
    [webview stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"speechSynthesis.speak(new SpeechSynthesisUtterance(\"%@\"));",text]];


No comments:

Post a Comment