【发布时间】:2012-08-19 00:57:04
【问题描述】:
我在 iOS 中使用 Google 文字转语音服务。
我可以使用以下代码进行英文 TTS。
NSString *queryTTS = [text stringByReplacingOccurrencesOfString:@" " withString:@"+"];
NSString *linkTTS = [NSString stringWithFormat:@"http://translate.google.com/translate_tts?tl=en&q=%@",queryTTS];
NSData *dataTTS = [NSData dataWithContentsOfURL:[NSURL URLWithString:linkTTS]];
_googlePlayer = [[AVAudioPlayer alloc] initWithData:dataTTS error:nil];
[_googlePlayer play];
所以我将 url 地址更改为语音泰国 TTS,如以下链接。
NSString *queryTTS = [text stringByReplacingOccurrencesOfString:@" " withString:@"+"];
NSString *linkTTS = [NSString stringWithFormat:@"http://translate.google.com/translate_tts?tl=th&q=%@",queryTTS];
NSData *dataTTS = [NSData dataWithContentsOfURL:[NSURL URLWithString:linkTTS]];
_googlePlayer = [[AVAudioPlayer alloc] initWithData:dataTTS error:nil];
[_googlePlayer play];
在我将该链接更改为 "th" 后,该 google TTS 服务无法说出我的泰文文本。
我的代码错了吗?
如果没有,我如何在 Google Text To Speech API 中更改语言?
感谢您的阅读。
【问题讨论】:
标签: ios text-to-speech