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

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...