iOS 10.3文本到语音在模拟器上工作,但不在设备上
问题描述:
我打电话给法语的文本到语音。iOS 10.3文本到语音在模拟器上工作,但不在设备上
这可按预期在: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];
}
答
原来的声音S ynthesizer由铃声音量控制,而不是媒体音量。振铃器在测试仪的设备上静音。
答
您的.h文件 添加AVSpeechSynthesizer* synthesizer = NULL;
,你是好go--我测试..它的工作原理超细:)
去你的.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];
}
请检查您的设备是否为静音模式。还要按音量调高设备音量。 –