我正在开发一个应用程序,我必须将字符串作为音频播放。
我正在使用http://translate.google.com/translate_tts?tl=en&q=Hello API来说出字符串,但它有点慢。
objective-c中是否有任何库可以将字符串作为音频“Text To Speech”播放。
答案 0 :(得分:19)
查看io7中的AVSpeechUtterance和AVSpeechSynthesizer类。基本上你可以做到以下几点。
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
AVSpeechSynthesizer *syn = [[[AVSpeechSynthesizer alloc] init]autorelease];
[syn speakUtterance:utterance];
答案 1 :(得分:8)
导入框架:
#import <AVFoundation/AVFoundation.h>
#import <QuartzCore/QuartzCore.h>
.m文件代码
NSString *str = @"Hello friend, how are you?";
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
AVSpeechUtterance *speechutt = [AVSpeechUtterance speechUtteranceWithString:strtext];
speechutt.volume=90.0f;
speechutt.rate=0.50f;
speechutt.pitchMultiplier=0.80f;
[speechutt setRate:0.3f];
speechutt.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-us"];
[synthesizer speakUtterance:speechutt];
用任何语言支持的voiceWithLanguage选项支持。
Arabic (Saudi Arabia) - ar-SA
Chinese (China) - zh-CN
Chinese (Hong Kong SAR China) - zh-HK
Chinese (Taiwan) - zh-TW
Czech (Czech Republic) - cs-CZ
Danish (Denmark) - da-DK
Dutch (Belgium) - nl-BE
Dutch (Netherlands) - nl-NL
English (Australia) - en-AU
English (Ireland) - en-IE
English (South Africa) - en-ZA
English (United Kingdom) - en-GB
English (United States) - en-US
French (Canada) - fr-CA
French (France) - fr-FR
Finnish (Finland) - fi-FI
German (Germany) - de-DE
Hindi (India) - hi-IN
Hungarian (Hungary) - hu-HU
Indonesian (Indonesia) - id-ID
Italian (Italy) - it-IT
Japanese (Japan) - ja-JP
Korean (South Korea) - ko-KR
Norwegian (Norway) - no-NO
Romanian (Romania) - ro-RO
Russian (Russia) - ru-RU
Slovak (Slovakia) - sk-SK
Spanish (Mexico) - es-MX
Swedish (Sweden) - sv-SE
Turkish (Turkey) - tr-TR
答案 2 :(得分:0)
Nuance NDEV Mobile iOS SDK可能是您在质量和性能方面最好的选择,但与OpenEars不同,它不是免费的。也就是说,我们有40种不同的语言和61种不同的语音,并且该库有一个不依赖于HTTP(并且仍然基于网络)的子系统,您可以使用它。
注册帐户后..
SpeechKit
Vocalizer
实例,指定语言或语音Vocalizer
实例与speakString
一起用于您要合成的文字willBeginSpeakingString:(NSString *)text
didFinishSpeakingString:(NSString *)text
注意:Vocalizer API也支持SSML。