Nothing to do, suddenly want to listen to the apple voice function, and then on their own information to do.
Before iOS7, you might need a third-party repository to implement voice-broadcast text content. Now on the IOS7, the system provides us with the function of voice broadcast text, we can not only broadcast English content, can also broadcast Chinese characters, so for developers is really a boon.
You need to import Avfoundattion:
Current device judgment
NSString *warnmsg = @ "The weather is really good today, work refueling";
if ([[[[Uidevice Currentdevice] Systemversion]integervalue]>=7.0) {
Avspeechutterance
Avspeechutterance is the set of text content that needs to be broadcast-warnmsg, speech rate-rate, and language type-preferredlang, and Avspeechsynthesizer is the class that starts to play synchronously.
Avspeechutterance *utterance =[avspeechutterance speechutterancewithstring:warnmsg];
Rate
Utterance.rate *= 0.8;
Sync Voice
Avspeechsynthesizer *synth = [[Avspeechsynthesizer alloc] init];
/**
* Get current system voice
*/
NSString *preferredlang = @ "";
setting of the language
Preferredlang = @ "ZH-HK";
Avspeechsynthesisvoice *voice =[avspeechsynthesisvoice voicewithlanguage:[nsstring stringWithFormat:@ "%@", Preferredlang]];
Utterance.voice = Voice;
[Synth speakutterance:utterance];
}
iOS Development--voice broadcast