美文网首页
支付宝到账1000元 iOS 语音播报

支付宝到账1000元 iOS 语音播报

作者: 秋叶红90 | 来源:发表于2021-02-01 09:48 被阅读0次
import AVKit
import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
//        AVSpeechSynthesizer * synthsizer = [[AVSpeechSynthesizer alloc] init];
//
//        AVSpeechUtterance * utterance = [[AVSpeechUtterance alloc] initWithString:@"aosika先生"];//需要转换的文本
//
//        utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"];//国家语言
//
//        utterance.rate = 0.4f;//声速
//
//        [synthsizer speakUtterance:utterance];
        
//        let path = Bundle.main.path(forResource: "sound", ofType: "wav")
//        let pathURL = NSURL(fileURLWithPath: path!)
//        do {
//        audioPlayer = try AVAudioPlayer(contentsOf: pathURL as URL)
//        } catch {
//        audioPlayer = nil
//        }
//        audioPlayer?.prepareToPlay()
//        audioPlayer?.play()
        
        
        let synthsizer = AVSpeechSynthesizer.init()
        let utterance = AVSpeechUtterance.init(string: "支付宝到账1000元")
        utterance.voice = AVSpeechSynthesisVoice.init(language: "zh-CN")
        utterance.rate = 0.52
        synthsizer.speak(utterance)
    }
    

}



相关文章

网友评论

      本文标题:支付宝到账1000元 iOS 语音播报

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