AVSpeechSynthesizer:
import UIKit
import AVFoundation
class SpeechSynthesizer: AVSpeechSynthesizer {
static let shared = SpeechSynthesizer()
func telling(command: String) {
let utterance = AVSpeechUtterance(string: command)
utterance.rate = 0.5
utterance.voice = AVSpeechSynthesisVoice(language: "zh-cmn")
self.speak(utterance)
}
}
网友评论