[英]ionic 4 speech recognition
我正在嘗試使用語音識別,但我不斷收到錯誤這是我的頁面
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)
);
}
}
有了這個我得到以下錯誤:
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'.
我使用離子 4
在導入時使用ngx import { SpeechRecognition } from '@ionic-native/speech-recognition/ngx';
也許你也應該作為提供者導入。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.