【问题标题】:iOS 10.3 text to speech works on simulator but not on deviceiOS 10.3 文本转语音适用于模拟器,但不适用于设备
【发布时间】:2017-06-03 20:06:44
【问题描述】:

我正在调用法语的文本到语音。

这在:iOS 9.3 模拟器、iOS 9.3 设备 (iPad 3rd gen)、iOS 10.3 模拟器上按预期工作。 在 iOS 10.3 设备 (iPhone 6s) 上无法(静默)工作。

默认法语语音已安装并根据设备设置工作。

static AVSpeechSynthesizer* synthesizer = NULL;
//...
+(void)readText:(NSString*)text
{
    if(synthesizer == NULL)
      synthesizer = [[AVSpeechSynthesizer alloc] init];
    AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
    utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"fr-FR"];
    [synthesizer speakUtterance:utterance];
}

【问题讨论】:

  • 请检查您的设备是否处于静音模式。还可以通过音量增大按钮检查设备音量。

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


【解决方案1】:

原来语音合成器是由铃声音量控制的,而不是媒体音量。测试人员设备上的铃声已静音。

【讨论】:

    【解决方案2】:

    在您的 .h 文件中 添加AVSpeechSynthesizer* synthesizer = NULL; 你很高兴 - 我已经测试过了..它工作得非常好:)

    转到您的 .h 文件并添加

    AVSpeechSynthesizer* synthesizer = NULL;
    

    在 .m 上

    -(void)readText:(NSString*)text
    {
        if(synthesizer == NULL)
          synthesizer = [[AVSpeechSynthesizer alloc] init];
        AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
        utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"fr-FR"];
        [synthesizer speakUtterance:utterance];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-15
      • 1970-01-01
      • 2012-11-01
      • 2011-03-08
      相关资源
      最近更新 更多