35 lines
864 B
JavaScript
35 lines
864 B
JavaScript
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
|
|
} |