본문 바로가기

시작하기

GitHub

AI-Assisted Setup으로 플러그인을 설치할 수 있습니다. 다음 명령어로 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.

수동 설정을 선호한다면, 다음 명령어를 실행하여 플러그인을 설치하고 아래의 플랫폼별 지침을 따르세요:

터미널 창
npm install @capgo/capacitor-speech-recognition
npx cap sync
import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';

마이크 권한을 요청하고, partialResults 리스너를 연결한 뒤 스트리밍 업데이트로 세션을 시작하세요.

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.requestPermissions();
const partialListener = await SpeechRecognition.addListener('partialResults', ({ matches }) => {
setTranscript(matches?.[0] ?? '');
});
await SpeechRecognition.start({ language: 'en-US', partialResults: true });
// When leaving the screen:
await SpeechRecognition.stop();
await partialListener.remove();

자주 하는 실수

“흔한 실수” 섹션
  • 정리: 화면을 벗어날 때 리스너를 제거하세요.
  • 로케일: UI와 일치하는 BCP 47 태그를 사용하세요.
  • 웹: 지원되지 않음; 웹 전용 받아쓰기가 필요한 경우 브라우저 speech API를 별도로 사용하세요.

현재 기기에서 네이티브 음성 인식 서비스를 사용할 수 있는지 확인합니다.

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
const result = await SpeechRecognition.available();
console.log(result);

isOnDeviceRecognitionAvailable

“isOnDeviceRecognitionAvailable” 섹션

선택한 로케일에서 플랫폼의 최신 온디바이스 인식 경로를 사용할 수 있는지 확인합니다.

기능을 활성화하기 전에 반드시 이 체크 로직을 사용해야 합니다. useOnDeviceRecognition. A true 결과가 true이면 현재 기기, OS 버전 및 로케일에서 해당 플랫폼의 최신 온디바이스(on-device) 경로를 사용할 수 있음을 의미합니다.

반환값 false 기기가 레거시 인식 경로만 지원하는 경우입니다.

플랫폼별 SDK 문서: iOS: Speech Android: SpeechRecognizer

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
const result = await SpeechRecognition.isOnDeviceRecognitionAvailable();
console.log(result);

오디오 캡처와 음성 전사를 시작합니다.

시기 partialResults 이며 true, 반환된 promise는 즉시 resolve되고 업데이트는 partialResults listener를 통해 세션이 종료될 때까지 스트리밍됩니다.

기본 경로는 하위 호환성을 위해 레거시 recognizer 동작을 유지합니다. useOnDeviceRecognition: true 확인한 후에만 전달하세요.

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
const result = await SpeechRecognition.start();
console.log(result);

- 듣기를 중단하고 네이티브 리소스를 해제합니다.

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

현재 세션을 강제로 종료합니다.

Android에서는 먼저 일반적인 중지(stop)를 시도한 후, 실패할 경우 destroy/recreate를 수행합니다. timeout. iOS에서는 현재 세션이 즉시 중지됩니다.

부분 텍스트(partial transcript)가 캐시되어 있다면, partialResults 다음 listener를 통해 전달됩니다: forced: true.

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

마지막으로 캐시된 부분 텍스트 변환 결과를 가져옵니다.

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
const result = await SpeechRecognition.getLastPartialResult();
console.log(result);

현재 push-to-talk 버튼 상태를 업데이트합니다.

다음과 함께 사용하세요: continuousPTT 또는 커스텀 hold-to-talk 플로우와 함께 사용하세요.

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
await SpeechRecognition.setPTTState({ held: true });

기반 인식기가 지원하는 로케일을 가져옵니다.

Android 13 이상 기기에서는 이 목록을 더 이상 제공하지 않으므로, languages 비어 있게 됩니다.

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
const result = await SpeechRecognition.getSupportedLanguages();
console.log(result);

플러그인이 현재 음성을 듣고 있는지 여부를 반환합니다.

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
const result = await SpeechRecognition.isListening();
console.log(result);

현재 권한 상태를 가져옵니다.

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
const result = await SpeechRecognition.checkPermissions();
console.log(result);

마이크 및 음성 인식 권한을 요청합니다.

import { SpeechRecognition } from '@capgo/capacitor-speech-recognition';
const result = await SpeechRecognition.requestPermissions();
console.log(result);

타입 레퍼런스

“타입 참조” 섹션

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

. 옵션

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

. 결과값

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

. 옵션

export interface PTTStateOptions {
/**
* Whether the PTT button is currently held.
*/
held: boolean;
}

SpeechRecognitionLanguages

“SpeechRecognitionLanguages” 섹션
export interface SpeechRecognitionLanguages {
languages: string[];
}

SpeechRecognitionListening

“SpeechRecognitionListening” 섹션
export 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.tsupstream에서 public API가 변경되면 sync를 다시 실행하세요.

사용 중이라면 시작하기 대시보드 및 API 운영을 계획하려면, 이를 다음과 연결하세요 @capgo/capacitor-speech-recognition 사용하기 @capgo/capacitor-speech-recognition 사용하기의 네이티브 기능을 위해, API 개요 구현 세부 사항은 API 개요에서 소개 구현 세부 사항은 소개에서 API 키 API Keys의 구현 세부 사항은, 기기 Devices의 구현 세부 사항은.