@capacitor-community/speech-recognition

中文文档
7.0.1发布于 2025/06/09MITTypeScriptESM + CJS零依赖近 30 天下载 46.3万

A native plugin for speech recognition

原始使用文档
文档目录18 节
  1. Maintainers
  2. Installation
  3. iOS
  4. Android
  5. Supported methods
  6. Example
  7. available()
  8. start(...)
  9. stop()
  10. getSupportedLanguages()
  11. isListening()
  12. checkPermissions()
  13. requestPermissions()
  14. addListener('partialResults', ...)
  15. addListener('listeningState', ...)
  16. removeAllListeners()
  17. Interfaces
  18. Type Aliases

Capacitor Speech Recognition Plugin

Capacitor community plugin for speech recognition.

Maintainers

MaintainerGitHubSocial
Priyank Patelpriyankpat@priyankpat_
Matteo Padovanomrbatista@mrba7ista

Maintenance Status: Actively Maintained

Installation

To use npm

npm install @capacitor-community/speech-recognition

To use yarn

yarn add @capacitor-community/speech-recognition

Sync native files

npx cap sync

iOS

iOS requires the following usage descriptions be added and filled out for your app in Info.plist:

  • NSSpeechRecognitionUsageDescription (Privacy - Speech Recognition Usage Description)
  • NSMicrophoneUsageDescription (Privacy - Microphone Usage Description)

Android

No further action required.

Supported methods

Example

import { SpeechRecognition } from "@capacitor-community/speech-recognition";

SpeechRecognition.available();

SpeechRecognition.start({
  language: "en-US",
  maxResults: 2,
  prompt: "Say something",
  partialResults: true,
  popup: true,
});
// listen to partial results
SpeechRecognition.addListener("partialResults", (data: any) => {
  console.log("partialResults was fired", data.matches);
});

// stop listening partial results
SpeechRecognition.removeAllListeners();

SpeechRecognition.stop();

SpeechRecognition.getSupportedLanguages();

SpeechRecognition.checkPermissions();

SpeechRecognition.requestPermissions();

SpeechRecognition.hasPermission();

SpeechRecognition.requestPermission();

available()

available() => Promise<{ available: boolean; }>

This method will check if speech recognition feature is available on the device.

Returns: Promise<{ available: boolean; }>


start(...)

start(options?: UtteranceOptions | undefined) => Promise<{ matches?: string[]; }>

This method will start to listen for utterance.

if partialResults is true, the function respond directly without result and event partialResults will be emit for each partial result, until stopped.

ParamType
optionsUtteranceOptions

Returns: Promise<{ matches?: string[]; }>


stop()

stop() => Promise<void>

This method will stop listening for utterance


getSupportedLanguages()

getSupportedLanguages() => Promise<{ languages: any[]; }>

This method will return list of languages supported by the speech recognizer.

It's not available on Android 13 and newer.

Returns: Promise<{ languages: any[]; }>


isListening()

isListening() => Promise<{ listening: boolean; }>

This method will check if speech recognition is listening.

Returns: Promise<{ listening: boolean; }>

Since: 5.1.0


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Check the speech recognition permission.

Returns: Promise<PermissionStatus>

Since: 5.0.0


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

Request the speech recognition permission.

Returns: Promise<PermissionStatus>

Since: 5.0.0


addListener('partialResults', ...)

addListener(eventName: 'partialResults', listenerFunc: (data: { matches: string[]; }) => void) => Promise<PluginListenerHandle>

Called when partialResults set to true and result received.

On Android it doesn't work if popup is true.

Provides partial result.

ParamType
eventName'partialResults'
listenerFunc(data: { matches: string[]; }) => void

Returns: Promise<PluginListenerHandle>

Since: 2.0.2


addListener('listeningState', ...)

addListener(eventName: 'listeningState', listenerFunc: (data: { status: 'started' | 'stopped'; }) => void) => Promise<PluginListenerHandle>

Called when listening state changed.

ParamType
eventName'listeningState'
listenerFunc(data: { status: 'started' | 'stopped'; }) => void

Returns: Promise<PluginListenerHandle>

Since: 5.1.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all the listeners that are attached to this plugin.

Since: 4.0.0


Interfaces

UtteranceOptions

PropTypeDescription
languagestringkey returned from getSupportedLanguages()
maxResultsnumbermaximum number of results to return (5 is max)
promptstringprompt message to display on popup (Android only)
popupbooleandisplay popup window when listening for utterance (Android only)
partialResultsbooleanreturn partial results if found

PermissionStatus

PropTypeDescriptionSince
speechRecognitionPermissionStatePermission state for speechRecognition alias. On Android it requests/checks RECORD_AUDIO permission On iOS it requests/checks the speech recognition and microphone permissions.5.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

版本与发布记录

@capacitor-community/speech-recognition 共发布 15 个版本,首次发布于 2020/06/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
7.0.1latest2025/06/091.4 年前
7.0.02025/03/261.6 年前
6.0.12024/06/282 年前
6.0.02024/06/082 年前
5.1.02024/03/272 年前
5.0.0-dev.f11750d.1711357142dev2024/03/252 年前

其他发布通道:next → 5.0.0-0,dev → 5.0.0-dev.f11750d.1711357142。

关于 @capacitor-community/speech-recognition 的常见问题

@capacitor-community/speech-recognition 是什么?

A native plugin for speech recognition

如何安装 @capacitor-community/speech-recognition?

在项目目录运行 npm install @capacitor-community/speech-recognition,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=7.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capacitor-community/speech-recognition 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capacitor-community/speech-recognition 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capacitor-community/speech-recognition 可以商用吗?

@capacitor-community/speech-recognition 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@capacitor-community/speech-recognition 的下载量有多少?

根据 npm 官方下载统计,@capacitor-community/speech-recognition 在 2026/10/09 – 2026/11/07 这 30 天内被下载 463,085 次,日均约 15,436 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capacitor-community/speech-recognition 还在维护吗?

最新版本 7.0.1 发布于 2025/06/09(1.4 年前);至今共发布 15 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/06/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。