[add] TTS 暫停等功能

This commit is contained in:
建喵 2022-08-26 10:28:11 +08:00
parent 04f398f3ef
commit 4ed7cf8119
3 changed files with 16 additions and 4 deletions

View File

@ -7,7 +7,7 @@
<key>JMKA-desktop.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
<integer>2</integer>
</dict>
<key>JMKA-mobile.xcscheme_^#shared#^_</key>
<dict>

View File

@ -13,16 +13,28 @@ class TTS_S: NSObject {
let synth = AVSpeechSynthesizer()
//
@IBAction func play(msg: String) {
let myUtterance = AVSpeechUtterance(string: msg)
myUtterance.voice = AVSpeechSynthesisVoice(language: "zh-TW")
myUtterance.rate = 0.5
synth.speak(myUtterance)
}
@IBAction func endHandler(_ sender: UIButton) {
synth.stopSpeaking(at: .word)
//
@IBAction func pause() {
synth.pauseSpeaking(at: .immediate)
}
//
@IBAction func continuePlay() {
synth.continueSpeaking()
}
//
@IBAction func stopPlay() {
synth.stopSpeaking(at: .immediate)
}
}