After searching through various resources, I haven't been able to find a solution for the issue I'm facing with an Android plugin. Hopefully, someone here can provide some help.
The problem lies in trying to make this plugin work on Android:
var app = require("application");
var context = android.content.Context;
var TextToSpeech = android.speech.tts.TextToSpeech;
var initialised = false;
var tts;
var text_to_speech = {
speak : function(text, queue, pitch, speakRate, volume){
if(!tts || !initialised) {
tts = new TextToSpeech(context, new TextToSpeech.OnInitListener({
onInit : function(status) {
// some code here
}
}));
}
}
};
However, I am encountering an exception when initializing the tts object:
JS: ORIGINAL STACKTRACE:
JS: Error: Cannot convert JavaScript object with id 683715827 at index 0
JS: at Error (native)
JS: at Object.text_to_speech.speak (/data/data/org.nativescript.CzystyDywan/files/app/tns_modules/nativescript-texttospeech/texttospeech.js:20:10)
JS: at TextToSpeech.speakText (/data/data/org.nativescript.CzystyDywan/files/app/pages/texttospeech/texttospeech.component.js:9:13)
JS: at DebugAppView._View_TextToSpeech0._handle_tap_4_0 (TextToSpeech.template.js:148:28)
JS: at Object.<anonymous> (/data/data/org.nativescript.CzystyDywan/files/app/tns_modules/@angular/core/src/linker/view.js:316:24)
JS: at ZoneDelegate.invoke (/data/data/org.nativescript.CzystyDywan/files/app/tns_modules/zone.js/dist/zone-node.js:281:29)
JS: at Object.NgZoneImpl.inner.inner.fork.onInvoke (/data/data/org.nativescript.CzystyDywan/files/app/tns_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
JS: at ZoneDelegate.invoke (/data/data/org.nativescript.CzystyDywan/files/app/tns_modules/zone.js/dist/zone-node.js:280:35)
JS: at Zone.runGuarded (/data/data/org.nativescript.CzystyDywan/files/app/tns_modules/zone.js/dist/zone-node.js:188:48)
JS: at Object.callback (/data/data/org.nativescript.CzystyDywan/files/app/tns_modules/zone.js/dist/zone-node.js:164:30)
JS: ERROR CONTEXT:
JS: [object Object]
W/System.err( 3701): at com.tns.Runtime.callJSMethodNative(Native Method)
W/System.err( 3701): at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
W/System.err( 3701): at com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
W/System.err( 3701): at com.tns.Runtime.callJSMethod(Runtime.java:712)
W/System.err( 3701): at com.tns.Runtime.callJSMethod(Runtime.java:693)
W/System.err( 3701): at com.tns.Runtime.callJSMethod(Runtime.java:683)
It seems that the issue is related to the implementation of the TextToSpeech.OnInitListener interface, but I can't pinpoint what's wrong. Any advice or similar experiences would be greatly appreciated. Thank you!