0

所以我在 swift 2.0 Xcode 7.1.1 上有一个完美的 AVSpeechSynthesizer(文本到语音),但我不知道如何让它像我们以正常速度甚至更慢的速度说话?代码:

 import UIKit
 import AVKit
 import AVFoundation

 class HomePage: UIViewController {
 let Voice = AVSpeechSynthesizer()

 override func viewDidLoad() {
    super.viewDidLoad()
 let TilteSpeakingText1 = AVSpeechUtterance(string: "Welcome back. The database should still be up for you")
            Voice.speakUtterance(TilteSpeakingText1)
            TilteSpeakingText1.rate = 0.003
            TilteSpeakingText1.pitchMultiplier = 0.60
            TilteSpeakingText1.volume = 0.75
            TilteSpeakingText1.postUtteranceDelay = 0.01
 }
}
4

3 回答 3

1

AVSpeechUtterance有一个 rate 属性。尝试降低利率。

于 2015-11-25T17:46:38.280 回答
1

在设置速率、音高和音量属性后说出话语:

//Voice.speakUtterance(TilteSpeakingText1) <-remove this
            TilteSpeakingText1.rate = 0.003
            TilteSpeakingText1.pitchMultiplier = 0.60
            TilteSpeakingText1.volume = 0.75
            TilteSpeakingText1.postUtteranceDelay = 0.01
Voice.speakUtterance(TilteSpeakingText1)//call here instead
于 2017-03-25T19:59:44.897 回答
1

尝试这个 -:

let speechUtterance: AVSpeechUtterance = AVSpeechUtterance(string: text)
speechUtterance.rate = AVSpeechUtteranceMaximumSpeechRate / 2.0
于 2021-12-20T10:01:39.050 回答