12345678910111213141516171819202122232425262728293031 |
- const AndroidTTS = {
- TextToSpeech: plus.android.importClass("android.speech.tts.TextToSpeech"),
- tts: null,
- toSpeak: function(content) {
- console.log(content)
- this.tts.speak(content, 0, null)
- },
- init: function() {
- var main = plus.android.runtimeMainActivity();
- var listner = new plus.android.implements("android.speech.tts.TextToSpeech.OnInitListener", {
- onInit: function(status) {
- console.log(`初始化结果${status}`)
- if (status == 0) {
- uni.showToast({
- title: 'tts初始化成功'
- })
- } else {
- uni.showToast({
- title: 'tts初始化失败'
- })
- }
- }
- });
- this.tts = new this.TextToSpeech(main, listner)
- console.log(this.tts)
- }
- }
- export default {
- AndroidTTS
- }
|