【问题标题】:text-to-speech using google API or AVspeech使用谷歌 API 或 AVspeech 的文本转语音
【发布时间】:2014-02-06 18:52:43
【问题描述】:

我需要使用某种文本转语音工具来发音多种语言。我试过这段代码:

 AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
 AVSpeechSynthesizer *syn = [[[AVSpeechSynthesizer alloc] init]autorelease];
[syn speakUtterance:utterance];

哪个很好用,但是由于我想使用多种语言,它似乎没有这个功能还是什么?如何选择语言?

如果上述方法不可行,我想使用 Google api

我怎么玩这个

http://translate.google.com/translate_tts?tl=en&q=Hello

在我的视图控制器中?

【问题讨论】:

    标签: ios objective-c text-to-speech


    【解决方案1】:

    这个真的很简单,功能肯定有,试试下面的:

    utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-gb"];
    

    如果您需要了解所有可用的语言,请将以下代码放在某处:

    NSArray* voices = [AVSpeechSynthesisVoice speechVoices];
    NSLog(@"Voices: (%d) %@", voices.count, voices);
    

    如果您需要有关 AVSpeechSynthesisVoice 的更多文档,请查看以下链接:

    https://developer.apple.com/library/ios/Documentation/AVFoundation/Reference/AVSpeechSynthesisVoice_Ref/Reference/Reference.html

    【讨论】:

      猜你喜欢
      • 2012-04-11
      • 2013-04-10
      • 2018-07-18
      • 1970-01-01
      • 1970-01-01
      • 2019-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多