ios - AVSpeechSynthesizer 文本转语音

标签 ios text-to-speech avspeechsynthesizer

带有 en-us 语音的 AVSpeechsynthesizer 的“A”发音是“大写 A”,但只想要“A”怎么办?

最佳答案

只有当字符串中只有单个字符时才会发生这种情况,

您可以使用此解决方法检查字符串长度是否为 1,然后将其转换为小写字符串,

NSString *stringToUtter = @"A";
if (stringToUtter.length==1) {
    stringToUtter = [stringToUtter lowercaseString];
}
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:stringToUtter];
utterance.rate = AVSpeechUtteranceMinimumSpeechRate;
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-us"];
[self.synthesizer speakUtterance:utterance];

关于ios - AVSpeechSynthesizer 文本转语音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38519154/

相关文章:

ios - AVSpeechSynthesizer - 如果 AVSpeechSynthesizer 正在说话并且已经停止说话

swift - 如何快速暂停和恢复 AVSpeechSynthesizer/AVSpeechUtterance?

Swift - 完成后重置/重启 SpeechSynthesizer

ios - 重新加载和调用 requestImageForAsset 时 UICollectionView 闪烁

ios - 在解析 JSON 数据期间在 UITableView 中滚动时卡住

Android TextToSpeech.speak 在 onActivityResult 中不起作用

android - SpeechToText synthesizeToFile 不排队

ios - Swift - 从完成 block 中解散 View Controller

ios - UIViewController 内的 UITableView 使用 Parse PFQueryTableViewController

javascript - 一个优秀的文本转语音 JavaScript 库