Speech Recognition

Contents

This plugin does speech recognition using cloud services

https://github.com/pbakondy/cordova-plugin-speechrecognition

Ionic 语音识别Speech Recognition插件的安装(Installation)

ionic cordova plugin add cordova-plugin-speechrecognition npm install @ionic-native/speech-recognition

Ionic 语音识别Speech Recognition插件支持的平台(Supported Platforms)

  • Android
  • iOS

Ionic 语音识别Speech Recognition插件的用法(Usage)

import { SpeechRecognition } from '@ionic-native/speech-recognition';

constructor(private speechRecognition: SpeechRecognition) { }

...



// Check feature available
this.speechRecognition.isRecognitionAvailable()
  .then((available: boolean) => console.log(available))

// Start the recognition process
this.speechRecognition.startListening(options)
  .subscribe(
    (matches: Array<string>) => console.log(matches),
    (onerror) => console.log('error:', onerror)
  )

// Stop the recognition process (iOS only)
this.speechRecognition.stopListening()

// Get the list of supported languages
this.speechRecognition.getSupportedLanguages()
  .then(
    (languages: Array<string>) => console.log(languages),
    (error) => console.log(error)
  )

// Check permission
this.speechRecognition.hasPermission()
  .then((hasPermission: boolean) => console.log(hasPermission))

// Request permissions
this.speechRecognition.requestPermission()
  .then(
    () => console.log('Granted'),
    () => console.log('Denied')
  )