Hi there,
I´m trying to use the speech recognition in my ionic3 App. The default-language is en-US, but I want to change it to German (de-DE). I´ve tried a lot to add these Options, but all were ignored without any issue. What is going wrong? Thx a lot! Cheers Marco
I did it like this:
My home.ts
import { SpeechRecognition } from '@ionic-native/speech-recognition';
constructor(
public speech: SpeechRecognition,
...
}
//speech
async hasPermission():Promise<boolean> {
try {
const permission = await this.speech.hasPermission();
console.log(permission);
return permission;
} catch(e) {
console.log(e);
}
}
async getPermission():Promise<void> {
try {
this.speech.requestPermission();
} catch(e) {
console.log(e);
}
}
listen(): void {
console.log('listen action triggered');
if (this.isListening) {
this.speech.stopListening();
this.toggleListenMode();
return;
}
this.toggleListenMode();
let _this = this;
let options = {
language: 'de-DE'
}
this.speech.startListening().subscribe(matches => {
this.showTextInput = true;
_this._zone.run(() => {
// matches [0] to avoid multiple suggestions
_this.textInputDiagnoses = matches[0];
})
}, error => console.error(error));
}
toggleListenMode():void {
this.isListening = this.isListening ? false : true;
console.log('listening mode is now : ' + this.isListening);
}
//end speech