i am trying to use Speech-recognition but i keep getting errors here is my page
import {Component} from '@angular/core';
import {SpeechRecognition} from '@ionic-native/speech-recognition';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
constructor(private speechRecognition: SpeechRecognition) {
this.speechRecognition.requestPermission()
.then(
() => console.log('Granted'),
() => console.log('Denied')
);
}
record() {
const options = {
language: 'da-DK',
prompt: '', // Android only
showPopup: true, // Android only
showPartial: false
};
this.speechRecognition.startListening(options)
.subscribe(
(matches: Array<string>) => console.log(matches),
(onerror) => console.log('error:', onerror)
);
}
}
With this i get the following errors:
RROR in src/app/home/home.page.ts(12,32): error TS2339: Property 'requestPermission' does not exist on type 'SpeechRecognition'.
[ng] src/app/home/home.page.ts(26,32): error TS2339: Property 'startListening' does not exist on type 'SpeechRecognition'.
Im using ionic 4
on import use ngx import { SpeechRecognition } from '@ionic-native/speech-recognition/ngx';
and maybe you shoul import as provider too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.