swift - 将 AVSpeechSynthesizer 用于中文拼音

标签 swift chinese-locale avspeechsynthesizer

在我的 Swift 程序中,我使用 AVSpeechSynthesizer 来发音汉字。这是我的方法:

static var synth = AVSpeechSynthesizer()

static func speak(string: String) 
{        
    let utterance = AVSpeechUtterance(string: string)
    utterance.voice = AVSpeechSynthesisVoice(language: "zh-CN")
    utterance.rate = 0.1

    synth.speak(utterance)
}  

通常,一个字符可以有多个发音。有没有办法使用 AVSpeechSynthesizer 给定拼音的字符发音。换句话说,我们不传递“高”字,而是传递拼音“gāo”。到目前为止,仅通过拼音在这种方法中还没有奏效。

非常感谢,

乔恩

最佳答案

我想我已经找到了答案,并将其发布以防其他人发现它有用。拼音应输入“gao1”,而不是“gāo”。看来它必须是小写的:即,“GAO1”似乎不起作用,但“gao1”却起作用。

关于swift - 将 AVSpeechSynthesizer 用于中文拼音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55711910/

相关文章:

swift/Firebase : Is there a way to check for an update in the Firebase Database in the background of an app?

ios - 特征集合中每个特征的不同图标

ios - 如何将混合模式效果应用于 UIImage?

iOS后台获取。获取 Firebase 数据库

java - 如何在java字符串中找到第一个汉字

java - 如何从 Android 上的 Locale 对象获取脚本?

ios - AVSpeechUtterance 静音模式下的发音

swift - 使用正确的百分号(即%)将百分比数字格式化为zh(简体中文)

swift - 使用 Swift 显示 AVSpeechSynthesizer 显示为字幕的内容

ios - AVAudioSession 与 AVSpeechUtterance 混合