为UILocalNotification启用TTS

时间:2015-07-09 05:13:11

标签: ios objective-c swift text-to-speech uilocalnotification

我的要求就像在后台启用UILocalNotification警报正文的TTS(文本到语音)。这样系统就会在显示相应的通知的同时读取警报正文。

非常感谢。

1 个答案:

答案 0 :(得分:0)

当您的本地通知进入 前景 应用时,您可以执行以下操作:

AVSpeechUtterance *utterance = [AVSpeechUtterance 
                                speechUtteranceWithString:@"Replace this sentence with contents of local notification"];
AVSpeechSynthesizer *synth = [[AVSpeechSynthesizer alloc] init];

[synth speakUtterance:utterance];

我不确定当应用程序在后台并且用户看不见时,可以使用合成器。

有关详细信息,请参阅this related question