[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>
|
<key>JMKA-desktop.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>3</integer>
|
<integer>2</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>JMKA-mobile.xcscheme_^#shared#^_</key>
|
<key>JMKA-mobile.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
@ -13,16 +13,28 @@ class TTS_S: NSObject {
|
|||||||
|
|
||||||
let synth = AVSpeechSynthesizer()
|
let synth = AVSpeechSynthesizer()
|
||||||
|
|
||||||
|
// 播放
|
||||||
@IBAction func play(msg: String) {
|
@IBAction func play(msg: String) {
|
||||||
|
|
||||||
let myUtterance = AVSpeechUtterance(string: msg)
|
let myUtterance = AVSpeechUtterance(string: msg)
|
||||||
myUtterance.voice = AVSpeechSynthesisVoice(language: "zh-TW")
|
myUtterance.voice = AVSpeechSynthesisVoice(language: "zh-TW")
|
||||||
myUtterance.rate = 0.5
|
myUtterance.rate = 0.5
|
||||||
synth.speak(myUtterance)
|
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