【发布时间】:2020-01-07 17:56:42
【问题描述】:
我正在使用**AVSpeechSynthesizer**,以下是向**AVSpeechSynthesizer** 传递文本的代码。
func speakOutText(_ textToRead:String ){
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(AVAudioSessionCategoryPlayback)
try audioSession.setMode(AVAudioSessionModeDefault)
try audioSession.setActive(true, with: .notifyOthersOnDeactivation)
} catch {
print("audioSession properties weren't set because of an error.")
}
let speakUtterance = AVSpeechUtterance.init(string: textToRead);
speakUtterance.voice = AVSpeechSynthesisVoice(language: "en-IN")
speakUtterance.pitchMultiplier = 1.2
speakUtterance.rate = 0.5
speechSynthesizer.speak(speakUtterance)
}
它以女性的声音正确地朗读文本。
但如果我在设置 -> Siri 和搜索 -> Siri 语音 -> 性别(男性) 中更改男性声音。再次调用speakOutText 方法,它只用女性语音朗读文本,而不是男性语音。
谁能告诉我原因,为什么它没有变成男声?
【问题讨论】:
标签: ios swift avspeechsynthesizer