AVSpeechSynthesizer高品质的声音

时间:2015-07-11 20:43:35

标签: ios avspeechsynthesizer

是否可以在语音合成器中使用增强/高品质的声音(美国的Alex)?我已经下载了声音,但没有办法告诉合成器使用它而不是默认声音。

由于声音通常由BCP-47代码选择,并且只有美国英语,因此似乎没有办法进一步区分声音。我错过了什么吗? (有人会认为Apple可能已经考虑过需要不同的方言,但我没有看到它。)

TIA。

2 个答案:

答案 0 :(得分:1)

是的,可以选择我系统上似乎可用的2,如下所示:

class Speak {

    let voices = AVSpeechSynthesisVoice.speechVoices()
    let voiceSynth = AVSpeechSynthesizer()
    var voiceToUse: AVSpeechSynthesisVoice?

  init(){
    for voice in voices {
      if voice.name == "Samantha (Enhanced)"  && voice.quality == .enhanced {
        voiceToUse = voice
      }
    }    
  }

    func sayThis(_ phrase: String){
      let utterance = AVSpeechUtterance(string: phrase)
          utterance.voice = voiceToUse
          utterance.rate = 0.5

        voiceSynth.speak(utterance) 
    }
}

然后,在您的应用中的某个位置,执行以下操作:

let voice = Speak()
voice.sayThis("I'm speaking better Seppo, now!")

答案 1 :(得分:0)

这是以前版本的iOS中的一个错误,使用合成器的应用程序没有使用增强的声音。此错误已在iOS10中修复。 iOS10现在使用增强的声音。