美文网首页
iOS文字转语音

iOS文字转语音

作者: 玉思盈蝶 | 来源:发表于2020-05-12 14:22 被阅读0次

    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)
        }
    
    }
    

    参考链接:

    https://www.jianshu.com/p/28288cedf634

    相关文章

      网友评论

          本文标题:iOS文字转语音

          本文链接:https://www.haomeiwen.com/subject/peybnhtx.html