首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >离子4语音识别

离子4语音识别
EN

Stack Overflow用户
提问于 2019-11-12 20:52:43
回答 1查看 165关注 0票数 0

我正在尝试使用语音识别,但是我一直收到错误--这里是我的页面

代码语言:javascript
复制
   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)
            );
    }

}

通过这个,我得到了以下错误:

代码语言:javascript
复制
    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使用离子4

EN

回答 1

Stack Overflow用户

发布于 2019-11-18 02:31:49

在导入时使用导入{ SpeechRecognition }从‘@离子型-本机/语音-识别/ngx’;

也许你也应该把进口当作供应商。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58826495

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档