Speech Recognition __CAPGO_KEEP_0__ リポジトリ
このプラグインのセットアッププロンプトをコピーして、インストール手順とフルマークダウンガイドを取得します。
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.
インストール
「インストール」のセクション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.Manual Setup を使用する場合は、以下のコマンドを実行して、下記のプラットフォーム固有の指示に従ってください:
bun add @capgo/capacitor-speech-recognitionbunx cap syncImport
「Import」のセクションimport { SpeechRecognition } from '@capgo/capacitor-speech-recognition';API の概要
「API の概要」のセクションavailable
利用可能なもの現在のデバイス上のネイティブの音声認識サービスが使用可能であるかどうかを確認します。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.available();isOnDeviceRecognitionAvailable
「isOnDeviceRecognitionAvailable」セクション選択されたロケールに対して、プラットフォームの最新のオンデバイス認識パスが利用可能かどうかを確認します。
この機能のチェックは、有効にする前に実行する必要があります。 useOnDeviceRecognition結果は、現在のデバイス、OSバージョン、ロケールがそのプラットフォームの新しいオンデバイスパスを使用できることを意味します。 true 結果は、デバイスがのみレガシーパス認識パスをサポートしていることを意味します。
プラットフォームのドキュメント: false iOS:
Platform SDK docs: iOS: Android: SpeechRecognizer Platform __CAPGO_KEEP_0__ docs:
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.isOnDeviceRecognitionAvailable();start
「start」のセクション音を記録し、会話を文字に変換します。
もし partialResults が true, すると返されたプロミスは即座に解決され、更新はセッション終了までリスナーを通じてストリーミングされます。 partialResults デフォルトのパスは、バックワード互換性のためにレガシーリコgnizerの動作を維持します。
パスを渡す前に、
を確認してください。
クリップボードにコピー useOnDeviceRecognition: true 「stop」のセクション
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.start();The default path keeps the legacy recognizer behavior for backward compatibility. Pass only after checking the following.
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.stop();forceStop
セクション「forceStop」現在のセッションを強制終了します。
Androidでは、通常の停止を試みてから、destroy/recreateにフォールバックします。 timeoutiOSでは、現在のセッションは即座に停止されます。
キャッシュされた部分的なトランスクリプトがあれば、リスナーに次のように通知されます。 partialResults クリップボードにコピー forced: true.
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.forceStop();getLastPartialResult
キャッシュされた部分的なトランスクリプトの最後の結果を取得します。クリップボードにコピー
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.getLastPartialResult();setPTTState
protectedTokens現在のスピーキングボタン状態を更新します。
この機能を使用するには 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
「SpeechRecognitionMatches」のセクションexport interface SpeechRecognitionMatches { matches?: string[];}ForceStopOptions
「ForceStopOptions」のセクションのオプション
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
「LastPartialResult」のセクションの結果
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
「PTTStateOptions」のセクションのオプション
export interface PTTStateOptions { /** * Whether the PTT button is currently held. */ held: boolean;}SpeechRecognitionLanguages
SpeechRecognitionLanguagesexport interface SpeechRecognitionLanguages { languages: string[];}SpeechRecognitionListening
SpeechRecognitionListeningexport interface SpeechRecognitionListening { listening: boolean;}SpeechRecognitionPermissionStatus
SpeechRecognitionPermissionStatus許可マップ checkPermissions と requestPermissions.
export interface SpeechRecognitionPermissionStatus { speechRecognition: PermissionState;}SpeechRecognitionSegmentResultEvent
SpeechRecognitionSegmentResultEventセグメント結果が生成されたときに発生 (Android 限定)
export interface SpeechRecognitionSegmentResultEvent { matches: string[];}SpeechRecognitionPartialResultEvent
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
「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がアップストリームで変更されたときに再度syncを実行してください。
Getting Startedから続けて
「Getting Startedから続けて」Capacitorを使用している場合 スタートガイド ダッシュボードとAPIの作業を計画するには、APIに接続する必要があります。 Capacitorの@capgo/capacitor-speech-recognitionを使用 Capacitorの@capgo/capacitor-speech-recognitionのネイティブ機能のために CapacitorのAPIオーバービュー CapacitorのAPIオーバービューの実装詳細 Capacitorのインストラクション Capacitorのインストラクションの実装詳細 CapacitorのAPIキー CapacitorのAPIキーの実装詳細、 Capacitorのデバイス Capacitorのデバイスの実装詳細