if (uni.getSystemInfoSync().platform == "ios") {
var AVAudioSession = plus.ios.importClass("AVAudioSession");
var AVSpeechSynthesizer = plus.ios.importClass("AVSpeechSynthesizer");
var AVSpeechUtterance = plus.ios.importClass("AVSpeechUtterance");
var AVSpeechSynthesisVoice = plus.ios.importClass("AVSpeechSynthesisVoice");
AVAudioSession.sharedInstance().setCategoryerror("AVAudioSessionCategoryPlayback", null);
var sppech = new AVSpeechSynthesizer();
var utterance = AVSpeechUtterance.speechUtteranceWithString("你的文字");
var voice = AVSpeechSynthesisVoice.voiceWithLanguage("zh-CN");
utterance.plusSetAttribute("voice",voice);
utterance.plusSetAttribute("rate", 0.65);// 0.65为速度,越大播报速度越快
sppech.speakUtterance(utterance);
// 监听播报完毕
var delegate = plus.ios.implements("AVSpeechSynthesizerDelegate", {
"speechSynthesizer:didFinishSpeechUtterance:":function(synthesizer,utterance){
console.log("播报完");
}
})
sppech.plusSetAttribute("delegate", delegate);
}

z***@163.com
- 发布:2021-06-01 18:07
- 更新:2022-09-01 16:12
- 阅读:961
6 个评论
要回复文章请先登录或注册
FullStack
4***@qq.com
4***@qq.com
4***@qq.com
f***@126.com
1***@qq.com