メインコンテンツにスキップ

Getting Started

GitHub

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-recognition
bunx cap sync
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';

available

利用可能

デバイス上のネイティブスピーチ認識サービスが利用可能であるかどうかを確認します。

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.available();

プラットフォームの最新のオンデバイス認識パスが選択されたロケールで利用可能かどうかを確認します。

この機能の有効化前に使用する必要がある機能チェックです。 useOnDeviceRecognition.\nCapgo true 結果は、現在のデバイス、OSバージョン、ロケールが、対応するプラットフォームの新しいデバイスパスを使用できることを意味します。

戻り値 false デバイスがレガシィ認識パスのみをサポートしている場合。

プラットフォーム SDK ドキュメント: iOS: 話し言葉 Android: 音声認識

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.isOnDeviceRecognitionAvailable();

start

開始

音声の収集と音声認識を開始します。

When partialResultstrue、返されたプロミスは即座に解決され、更新は リスナーを通じてセッション終了までストリーミングされます。 partialResults デフォルトのパスは、後方互換性のためにレガシーリコgnizerの動作を維持します。 パス

useOnDeviceRecognition: true にのみ渡すことができます。 確認する前に

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.start();

stop

終了

__CAPGO_KEEP_0__を停止し、ネイティブリソースを解放します。

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.stop();

現在のセッションを強制終了します。

Androidでは、通常の停止を試みてからdestroy/recreateにフォールバックします。 timeoutiOSでは、現在のセッションは即座に停止されます。

キャッシュされた部分トランスクリプトがあれば、listenerに partialResults __CAPGO_KEEP_1__で送信されます。 forced: true.

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.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

isListening

プラグインが音声認識を実行しているかどうかを返します。

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.isListening();

現在の許可状態を取得します。

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.checkPermissions();

マイク + 会話認識の許可を要求します。

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.requestPermissions();
export interface SpeechRecognitionAvailability {
available: boolean;
}

__CAPGO_KEEP_0__の呼び出し時に認識器がどのように振る舞うかを設定します。

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;
}
export interface SpeechRecognitionMatches {
matches?: string[];
}

__CAPGO_KEEP_0__のオプション

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;
}

__CAPGO_KEEP_0__の結果

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[];
}

__CAPGO_KEEP_0__のオプション

export interface PTTStateOptions {
/**
* Whether the PTT button is currently held.
*/
held: boolean;
}
export interface SpeechRecognitionLanguages {
languages: string[];
}
export interface SpeechRecognitionListening {
listening: boolean;
}

__CAPGO_KEEP_0__によって返される許可マップ checkPermissionsrequestPermissions.

export interface SpeechRecognitionPermissionStatus {
speechRecognition: PermissionState;
}

__CAPGO_KEEP_0__がAndroidのみで生成されるセグメント結果を生成したときに発生します。

export interface SpeechRecognitionSegmentResultEvent {
matches: string[];
}

部分的な音声認識結果が生成されたときに発生します。

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;
}

リスニング状態が変更されたときに発生します。

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 を計画ダッシュボードとAPI オペレーションに接続する必要があります。 Using @capgo/capacitor-speech-recognition native capabilityのためにUsing @capgo/capacitor-speech-recognition API Overview APIの実装詳細についてはAPI Overview Introduction 実装詳細についてはIntroduction API Keys API Keysの実装詳細については Devices __CAPGO_KEEP_0__の実装詳細についての情報は、デバイスのページにあります。