はじめに
このプラグインの全体のマークダウンガイドとインストールステップを含む設定プロンプトをコピーしてください。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-speech-recognition`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/speech-recognition/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」と題されたセクションCapgoのAI-Assistedセットアップを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを使用してください:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のプロンプトを使用してください:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-speech-recognition` plugin in my project.If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:
bun add @capgo/capacitor-speech-recognitionbunx cap syncImport
__CAPGO_KEEP_0__import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';API Overview
Section titled “API Overview”available
__CAPGO_KEEP_0____CAPGO_KEEP_0__
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.available();isOnDeviceRecognitionAvailable
isOnDeviceRecognitionAvailableのセクション選択したロケールで利用可能なプラットフォームの最新のオンデバイス認識パスを確認します。
この機能を有効にする前に使用する機能チェックです。 useOnDeviceRecognition.
A true 結果は、現在のデバイス、OSバージョン、ロケールがそのプラットフォームの最新のオンデバイスパスを使用できることを意味します。
Returns false デバイスがレガシーリコGNIZERパスのみをサポートしている場合に返されます。
Platform SDK ドキュメント: iOS: Speech Android:
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.isOnDeviceRecognitionAvailable();音声の収集と会話の文字起こしを開始します。
「」の場合、 partialResults はすぐに解決され、セッションが終了するまでの間、 trueリスナーを通じて更新がストリーミングされます。 partialResults デフォルトのパスは、後方互換性のためにレガシーリコGNIZERの動作を維持します。
パスを渡す前に、
を確認してください。 useOnDeviceRecognition: true コピー
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.start();コピー
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.stop();forceStop
Section titled “forceStop”現在のセッションを強制終了します。
Androidの場合、通常の終了を試みてからdestroy/recreateにフォールバックします。 timeoutiOSの場合、現在のセッションは即座に終了されます。
キャッシュされた部分的なトランスクリプトが残っている場合、その部分的なトランスクリプトはリスナーに「 partialResults 」で送信されます。 forced: true.
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.forceStop();getLastPartialResult
Section titled “getLastPartialResult”最後のキャッシュされた部分的なトランスクリプト結果を取得します。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.getLastPartialResult();setPTTState
Section titled “setPTTState”現在のプッシュ・トゥ・トークン・ボタンの状態を更新します。
この機能を使用するには continuousPTT またはカスタムのホールドトゥートークフローと組み合わせてください。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.setPTTState({} as PTTStateOptions);getSupportedLanguages
「getSupportedLanguages」セクション認識エンジンによってサポートされるロケールを取得します。
Android 13+ デバイスでは、このリストは公開されなくなりました。 languages その場合、空になります。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.getSupportedLanguages();isListening
「isListening」セクションプラグインが音声認識を実行しているかどうかを確認します。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.isListening();checkPermissions
「checkPermissions」セクション現在の許可状態を取得します。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.checkPermissions();requestPermissions
「requestPermissions」セクションマイク + 会話認識の許可を要求します。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.requestPermissions();型参照
「型参照」セクションSpeechRecognitionAvailability
「SpeechRecognitionAvailability」セクションexport interface SpeechRecognitionAvailability { available: boolean;}SpeechRecognitionStartOptions
「SpeechRecognitionStartOptions」セクション認識器の動作を設定します。
export interface SpeechRecognitionStartOptions { /** * Locale identifier such as `en-US`. When omitted the device language is used. */ language?: string; /** * Maximum number of final matches returned by native APIs. Defaults to `5`. */ maxResults?: number; /** * Prompt message shown inside the Android system dialog (ignored on iOS). */ prompt?: string; /** * When `true`, Android shows the OS speech dialog instead of running inline recognition. * Defaults to `false`. */ popup?: boolean; /** * Emits partial transcription updates through the `partialResults` listener while audio is captured. */ partialResults?: boolean; /** * Enables native punctuation handling where supported (iOS 16+). */ addPunctuation?: boolean; /** * Opt in to the platform's newer on-device recognition path when available. * * On iOS 26+, this uses Apple's `SpeechAnalyzer` / `SpeechTranscriber` pipeline. * On recent Android versions, this uses the on-device `SpeechRecognizer` path. * * It is intentionally opt-in so existing apps keep the legacy flow unless they choose * to roll out the new behavior. * * Use {@link SpeechRecognitionPlugin.isOnDeviceRecognitionAvailable} before enabling it in production. * * Platform SDK docs: * iOS: [Speech](https://developer.apple.com/documentation/speech), * [SpeechAnalyzer](https://developer.apple.com/documentation/speech/speechanalyzer), * [SpeechTranscriber](https://developer.apple.com/documentation/speech/speechtranscriber) * Android: [SpeechRecognizer](https://developer.android.com/reference/android/speech/SpeechRecognizer) * * Defaults to `false`. */ useOnDeviceRecognition?: boolean; /** * Allow a number of milliseconds of silence before splitting the recognition session into segments. * Required to be greater than zero and currently supported on Android only. */ allowForSilence?: number; /** * EXPERIMENTAL: Keep a PTT session alive across silence by restarting recognition while the button stays held. * * This restart behavior is implemented for Android inline recognition and iOS native recognition. */ continuousPTT?: boolean;}SpeechRecognitionMatches
Section titled “”export interface SpeechRecognitionMatches { matches?: string[];}ForceStopOptions
Section titled “”Options for
export interface ForceStopOptions { /** * Android only: timeout in milliseconds before forcing stop via destroy/recreate. * * On iOS, the current session is stopped immediately and this value is ignored. * * Defaults to `1500`. */ timeout?: number;}LastPartialResult
Section titled “”Result from
export interface LastPartialResult { /** * Whether a partial result is currently cached. */ available: boolean; /** * The most recent transcript text known to the native recognizer. */ text: string; /** * All current match alternatives when available. */ matches?: string[];}PTTStateOptions
Section titled “”Options for
export interface PTTStateOptions { /** * Whether the PTT button is currently held. */ held: boolean;}SpeechRecognitionLanguages
Section titled “”export interface SpeechRecognitionLanguages { languages: string[];}SpeechRecognitionListening
「音声認識リスニング」セクションexport interface SpeechRecognitionListening { listening: boolean;}SpeechRecognitionPermissionStatus
「音声認識許可状態」セクション__CAPGO_KEEP_0__によって返される許可マップ checkPermissions と requestPermissions.
export interface SpeechRecognitionPermissionStatus { speechRecognition: PermissionState;}SpeechRecognitionSegmentResultEvent
「音声認識セグメント結果イベント」セクションAndroidのみで、セグメント結果が生成されたときに発生します。
export interface SpeechRecognitionSegmentResultEvent { matches: string[];}SpeechRecognitionPartialResultEvent
「音声認識部分結果イベント」セクション部分的な音声認識結果が生成されたときに発生します。
export interface SpeechRecognitionPartialResultEvent { /** * Current recognition matches when the native recognizer reports them. * * This can be omitted for forced or accumulated-only payloads. */ matches?: string[]; /** * Accumulated transcription from earlier continuous PTT cycles. */ accumulated?: string; /** * Final accumulated text including the current result. */ accumulatedText?: string; /** * `true` when the plugin is restarting recognition inside a continuous PTT session. */ isRestarting?: boolean; /** * `true` when the payload was emitted by `forceStop()`. */ forced?: boolean;}SpeechRecognitionListeningEvent
セクション「音声認識リスニングイベント」リスニング状態が変化したときに発生します。
export interface SpeechRecognitionListeningEvent { /** * Finite state of the recognition session. */ state?: ListeningFiniteState; /** * Unique identifier for the current listening session. */ sessionId?: number; /** * Why this state transition occurred. */ reason?: ListeningReason; /** * Error code when the transition is caused by an error. */ errorCode?: string; /** * Backward-compatible binary state used by earlier releases. */ status?: 'started' | 'stopped';}真実の源
セクション「真実の源」このページはプラグインの src/definitions.ts. 公開 API がアップストリームで変更されたときに再度同期してください。
始めてから続けて
セクション「始めてから続けて」あなたが使用している場合 始めてから続けて ダッシュボードとAPIの運用計画を行うには、 Using @capgo/capacitor-speech-recognition Using @capgo/capacitor-speech-recognitionのネイティブ機能 APIの概要 APIの概要の実装詳細 導入 導入の実装詳細 APIのキー APIのキーと実装詳細 デバイス デバイスの実装詳細