在我的 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/