[add] TTS 暫停等功能
This commit is contained in:
parent
04f398f3ef
commit
4ed7cf8119
Binary file not shown.
@ -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>
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user