始めてみる
インストールステップとこのプラグインのフルマークダウンガイドまでの全てのステップを含む設定プロンプトをコピーする
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.
インストール
「インストール」のセクションbun add @capgo/capacitor-speech-recognitionbunx cap syncインポート
「インポート」のセクションimport { SpeechRecognition } from '@capgo/capacitor-speech-recognition';API オーバービュー
「API オーバービュー」のセクションavailable
利用可能現在のデバイスで使用可能なネイティブの音声認識サービスが利用できるかどうかを確認します。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.available();isOnDeviceRecognitionAvailable
利用可能かどうか現在のデバイス、OSバージョン、ロケールで利用可能なプラットフォームの新しいオンデバイス認識パスが選択されたロケールで利用可能かどうかを確認します。
この機能を有効にする前に使用する必要がある機能チェックです。 useOnDeviceRecognition結果は、現在のデバイス、OSバージョン、ロケールがそのプラットフォームの新しいオンデバイスパスを使用できることを意味します。 true 結果は、デバイスがレガシィの認識パスのみをサポートしていることを意味します。
プラットフォームドキュメント: false iOS:
Platform SDK docs: iOS: __CAPGO_KEEP_0__ Android: SpeechRecognizer
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.isOnDeviceRecognitionAvailable();start
「start」タイトルのセクション音声の録音と文字起こしを開始します。
すると 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 “forceStop”
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.getLastPartialResult();setPTTState
「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
__CAPGO_KEEP_0____CAPGO_KEEP_0__が活発に話し言葉を検出しているかどうかを返します。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.isListening();checkPermissions
許可を確認するセクション__CAPGO_KEEP_0__の現在の許可状態を取得します。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.checkPermissions();requestPermissions
許可を要求するセクションマイク + 話し言葉認識の許可を要求します。
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.requestPermissions();型参照
型参照セクション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のセクション__CAPGO_KEEP_0__の設定
export interface PTTStateOptions { /** * Whether the PTT button is currently held. */ held: boolean;}SpeechRecognitionLanguages
音声認識言語の設定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 の公開変更が上流で再実行するときに生成されます。
「はじめから始める」から続けてください
「Getting Started」から続けてくださいあなたは「を使用しています Getting Started ダッシュボードとAPIの操作を計画する場合、を接続してください native capabilityのために@capgo/capacitor-speech-recognitionを使用する native capabilityのために@capgo/capacitor-speech-recognitionを使用する APIの概要 APIの実装詳細 概要 概要の実装詳細 APIのキー APIのキー実装詳細 デバイス デバイスの実装詳細について