2015-07-11 40 views
5

是否可以使用語音合成器的增強型/高品質音色(美國的Alex)?我已經下載了聲音,但沒有辦法告訴合成器使用它而不是默認聲音。AVSpeechSynthesizer高品質音色

由於聲音一般由BCP-47代碼選擇,並且僅適用於美國英語,因此似乎無法進一步區分聲音。我錯過了什麼嗎? (人們可能會認爲蘋果可能已經考慮了對不同方言的需求,但我沒有看到它)。

TIA。

+0

有同樣的問題,在我看來,它目前只是破碎,因爲這應該工作。根據文檔,它應該自動使用增強的語音(如果有的話)。 –

回答

0

這是以前版本的iOS中的一個錯誤,即使用合成器的應用程序未使用增強的聲音。該錯誤已在iOS10中修復。 iOS10現在使用增強的聲音。

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!")