5

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

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

TIA。

4

2 回答 2

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!")
于 2016-11-07T09:52:10.500 回答
0

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

于 2016-10-20T10:11:43.567 回答