简体   繁体   English

iOS 10.3文本语音转换可在模拟器上运行,但不能在设备上运行

[英]iOS 10.3 text to speech works on simulator but not on device

I'm calling text to speech for the French language. 我正在用法语讲文本。

This works as expected on: iOS 9.3 simulator, iOS 9.3 device ( iPad 3rd gen ), iOS 10.3 simulator. 它可以在以下iOS 9.3上正常运行: iOS 9.3模拟器, iOS 9.3设备( iPad 3rd gen ), iOS 10.3模拟器。 Does not work (silently) on iOS 10.3 device ( iPhone 6s ). iOS 10.3设备( iPhone 6s )上不起作用(无提示)。

Default French voice is installed and works according to device settings. 默认法语语音已安装并根据设备设置工作。

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];
}

Turns out the speech synthesizer is controlled by the ringer volume, not the media volume. 事实证明,语音合成器是由铃声音量而不是媒体音量控制的。 The ringer was muted on the tester's device. 铃声已在测试仪的设备上静音。

on your .h file add AVSpeechSynthesizer* synthesizer = NULL; 在您的.h文件中,添加AVSpeechSynthesizer* synthesizer = NULL; and you're good to go-- i have tested it.. it works super fine :) 而且你很好-我已经测试过了..它工作得很好:)

go to your .h file and add 转到您的.h文件并添加

AVSpeechSynthesizer* synthesizer = NULL;

and on the .m one 在.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];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM