TMRAppBle/script/module/tts.js

35 lines
864 B
JavaScript
Raw Normal View History

2023-10-19 15:00:17 +08:00
var tts;
var TTSUtil = {
initTTS:function(){
tts = api.require('iflyRecognition');
tts.createUtility({
android_appid: '3cbf130a'
}, function(ret, err) {
if (ret.status) {
// console.log("tts创建成功");
} else {
console.log("tts创建失败");
}
});
},
readStr:function(param){
tts.stopRead();
tts.read({
readStr: param.str,
speed: 0,
volume: 100,
voice: param.voice,
rate: 16000,
audioPath: 'fs://speechRecogniser/read.mp3'
}, function(ret, err) {
if (ret.status) {
ret.speakProgress
} else {
console.log(JSON.stringify(err));
}
});
},
}
export {
TTSUtil
}