我打电话的iOS文本到语音在一个相当标准的方法:完成iOS文本到语音转换工作时铃声静音
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];
}
它的工作,但有一个问题:当铃声是在设备静音,文本到语音也是静音的。即使铃声静音,我如何使其工作?
我猜想这正是铃声是为制作。因此,没有像您这样的开发人员可以绕过静音状态并播放声音,而用户期望手机保持安静。 – LinusGeffarth
以前我认为铃声仅用于静音电话和信息。现在很明显,它比这更复杂:[http://artoftheiphone.com/2012/02/10/basics-what-does-the-iphone-ringer-switch-mute-and-not-mute/]。尽管如此,许多应用程序确实会在铃声关闭的情况下发出声音(例如,浏览器正在播放YouTube),我想绕过它,因为这似乎是我预期的行为。 – Antonio
@LinusGeffarth nope,即使设备静音,也可以激活音频。 –