2014-10-05 73 views
-2

开始制作应用程序,实际上无法在网上找到任何东西,但这可能与iOS ....我想做一个简单的应用程序,可以说这个词大声说我已经选择了,然后用户可以尝试拼写这个词。iOS在屏幕上大声说出拼写游戏的文字

+0

谷歌的iOS游戏的声音? – chris 2014-10-05 10:15:56

回答

1

This blog post作者NSHipster详细描述了如何在iOS上使用文本到语音API。

这里所提供的示例代码的摘录:

NSString *string = @"Hello, World!"; 
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:string]; 
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; 

AVSpeechSynthesizer *speechSynthesizer = [[AVSpeechSynthesizer alloc] init]; 
[speechSynthesizer speakUtterance:utterance];