|
|
1 day ago | |
|---|---|---|
| .. | ||
| android | 1 day ago | |
| .DS_Store | 1 day ago | |
| CHANGLOG.md | 1 day ago | |
| README.md | 1 day ago | |
| package.json | 1 day ago | |
安卓原生离线语音合成引擎工具插件 包含两个工具:MT-TTS-Speech(调用系统已安装TTS)、MT-TTS-Baidu(调用百度离线SDK,需要自行购买授权)
调用安卓系统已安装的TTS进行语音合成播放
const TTSSpeech = uni.requireNativePlugin("MT-TTS-Speech");
init(callback, engineName?)getInstallTTS(([{label, name}])=>{})setEngine(engineName)setPitch(num) 0-100, 默认 50setSpeed(num) 0-100, 默认 50isSpeeking()setLanguage(name) 默认中文speek({text: 'test'})stop()destroy()openSetting()onStart(callback)onDone(callback)onError(callback)TTSSpeech.getInstallTTS(list => {
list.forEach(v => console.log(`引擎名 ${v.label} 包名:${v.name}`));
})
TTSSpeech.init((status) => {
if(status === 0){
console.log('引擎初始化成功')
TTSSpeech.speek({ text: '语音播放成功'})
}
}, 'com.iflytek.speechcloud')
调用百度离线SDK,需要购买百度授权
const TTSBaidu = uni.requireNativePlugin("MT-TTS-Baidu");
init(options, callback)setPitch(num) 范围 0-9,默认5setSpeed(num) 范围 0-9,默认5setVolumn(num) 范围 0-9,默认15isSpeeking()speek(text, utteranceId)changeSpeeker(text) text: F(度小美)、M(度小宇)、Y(度丫丫)、X(度逍遥), 成功返回0stop()paused()resume()destroy()onStart(callback)onDone(callback)onError(callback)TTSBaidu.init({
appId: '',
appKey: '',
secretKey: '',
sn: '', // 序列号
}, (status) => {
if(status === 0){
console.log('初始化成功')
TTSBaidu.speek('语音播放成功!');
}
})