Objective
Before IOS7, general speech recognition is relying on some third-party libraries, or using Google Voice interface, where Google's voice interface is best.
The great Google ~ ~ but now upgraded iOS with text to voice is also very good, support a lot of text, but the sound is a bit harsh:
The implementation of IOS 7 text-turn speech
Implementing TTS relies primarily on avspeechsynthesizer,avspeechutterance,avspeechsynthesisvoice, which must first be joined
Avfoundation Framework:
Avspeechsynthesisvoice: Used to configure pronunciation and to support a lot of pronunciation. Personal feeling Taiwan sounds best to listen ~ by calling
The [Avspeechsynthesisvoicespeechvoices] class method can be used to see the type of pronunciation supported;
Avspeechutterance: This class is used to make the string composition for the speech object provided to the Avspeechsynthesizer to play, this class also has some
Instance methods are used to control speed, tone, and so on.
Implementation code:
Avspeechutterance *utterance = [avspeechutterancespeechutterancewithstring:@ "Hello"];
English pronunciation
Avspeechsynthesisvoice *voice = [avspeechsynthesisvoicevoicewithlanguage:@ "EN-GB"];
Utterance.voice = Voice;
NSLog (@ "%@", [avspeechsynthesisvoicespeechvoices]);
Avspeechsynthesizer *synth = [[Avspeechsynthesizeralloc]init];
[Synth speakutterance:utterance];
Using the SDK's own method to implement TTS is very simple, but only IOS7 to support these methods, all still need to find a workaround;
Using the Google interface to implement TTS
The common way to use Google interface to text-to-speech text is to upload a text to Google's interface, and then return it to a MP3-formatted audio. Download down to play. This method is rather troublesome.
I found a way to be lazy when I used the webview. There is a property in the webview that can play the streaming media on the page automatically, as long as you set this property and you don't have to download it straight
The audio is then played.
Implementation code
NSString *str = [nsstringstringwithformat:@ "http://translate.google.com/translate_tts?tl=en&q=%@", @ "Hello"];
Nsurl *url = [NSURLURLWITHSTRING:STR];
Nsurlrequest *request = [[Nsurlrequestalloc]initwithurl:url];
UIWebView *webview = [[Uiwebviewalloc]init];
Webview.allowsinlinemediaplayback = yes;//Set this property WebView will automatically broadcast streaming media on the Web page, the ipad is the default yes;
IPhone Safari defaults to NO. IPad Safari defaults to YES
Now just load this page and the text you choose will be played when the load is complete.
[Self.webViewloadRequest:request];
PS: Next I will write some speech recognition on the iOS content, in iOS recorded in the PCM format of the recording into the FLAC format, and then upload to Google Interface for speech recognition, interested in continued attention ~ ~