我正在为法语拨打电话。
这符合预期: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];
}
答案 0 :(得分:3)
结果语音合成器由铃声音量控制,而不是媒体音量。铃声在测试仪的设备上静音。
答案 1 :(得分:0)
添加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];
}