【问题标题】:AVSpeechSynthesizer High Quality VoicesAVSpeechSynthesizer 高品质声音
【发布时间】:2015-07-11 20:43:34
【问题描述】:

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

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

TIA。

【问题讨论】:

  • 有同样的问题,在我看来,它目前只是被破坏了,因为这应该可以工作。根据文档,它应该自动使用增强的语音(如果可用)。

标签: ios avspeechsynthesizer


【解决方案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!")

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      • 1970-01-01
      相关资源
      最近更新 更多