시작하기
설치 단계와 이 플러그인에 대한 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-speech-synthesis`
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-synthesis/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 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-synthesis` plugin in my project.만약 Manual Setup을 선호한다면, 플러그인을 설치하기 위해 다음 명령어를 실행하고 아래에 플랫폼에 따라 설명된 지침을 따르세요:
bun add @capgo/capacitor-speech-synthesisbunx cap syncimport { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';API 개요
Section titled “API 개요”speak
Section titled “말하기”지정된 옵션으로 주어진 텍스트를 말합니다. 말하기 큐에 발화가 추가됩니다.
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const result = await SpeechSynthesis.speak({ text: 'Hello, world!', language: 'en-US', rate: 1.0, pitch: 1.0, volume: 1.0, queueStrategy: 'Add'});console.log('Utterance ID:', result.utteranceId);synthesizeToFile
Section titled “synthesizeToFile”음성 합성을 위한 오디오 파일로 변환합니다 (Android/iOS만). 오디오 파일이 저장된 경로를 반환합니다.
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const result = await SpeechSynthesis.synthesizeToFile({ text: 'Hello, world!', language: 'en-US'});console.log('Audio file saved at:', result.filePath);cancel
Section titled “취소”모든 큐된 발화와 현재 음성 합성을 취소합니다.
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.cancel();pause
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.pause();resume
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.resume();isSpeaking
__CAPGO_KEEP_1____CAPGO_KEEP_4__
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { isSpeaking } = await SpeechSynthesis.isSpeaking();console.log('Is speaking:', isSpeaking);isAvailable
__CAPGO_KEEP_1____CAPGO_KEEP_5__
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { isAvailable } = await SpeechSynthesis.isAvailable();if (isAvailable) { console.log('Speech synthesis is available');}getVoices
__CAPGO_KEEP_1__ (getVoices)__CAPGO_KEEP_2__
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { voices } = await SpeechSynthesis.getVoices();voices.forEach(voice => { console.log(`${voice.name} (${voice.language})`);});getLanguages
__CAPGO_KEEP_1__ (getLanguages)__CAPGO_KEEP_2__
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { languages } = await SpeechSynthesis.getLanguages();console.log('Available languages:', languages);isLanguageAvailable
__CAPGO_KEEP_1__ (isLanguageAvailable)__CAPGO_KEEP_2__
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { isAvailable } = await SpeechSynthesis.isLanguageAvailable({ language: 'es-ES'});console.log('Spanish available:', isAvailable);isVoiceAvailable
__CAPGO_KEEP_1__ (isVoiceAvailable)__CAPGO_KEEP_2__
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { isAvailable } = await SpeechSynthesis.isVoiceAvailable({ voiceId: 'com.apple.ttsbundle.Samantha-compact'});console.log('Voice available:', isAvailable);initialize
초기화iOS 최적화를 위한 음성 합성 엔진을 초기화합니다. 이 기능은 첫 번째 음성 요청 시 지연 시간을 줄일 수 있습니다.
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.initialize();activateAudioSession
음성 활성화iOS에서만 특정 카테고리와 함께 음성 세션을 활성화합니다.
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.activateAudioSession({ category: 'Playback'});deactivateAudioSession
음성 비활성화iOS에서만 음성 세션을 비활성화합니다.
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.deactivateAudioSession();타입 참조
타입 참조SpeakOptions
SpeakOptions말하기 옵션
export interface SpeakOptions { /** * The text to speak. * * @since 1.0.0 */ text: string;
/** * The BCP-47 language tag (e.g., 'en-US', 'es-ES'). * * @since 1.0.0 */ language?: string;
/** * The voice identifier to use. * * @since 1.0.0 */ voiceId?: string;
/** * The pitch of the voice (0.5 to 2.0, default: 1.0). * * @since 1.0.0 */ pitch?: number;
/** * The speaking rate (0.1 to 10.0, default: 1.0). * * @since 1.0.0 */ rate?: number;
/** * The volume (0.0 to 1.0, default: 1.0). * * @since 1.0.0 */ volume?: number;
/** * The queue strategy: 'Add' to append or 'Flush' to replace queue. * Default: 'Add' * * @since 1.0.0 */ queueStrategy?: 'Add' | 'Flush';}SpeakResult
SpeakResult말하기 결과
export interface SpeakResult { /** * Unique identifier for this utterance. * * @since 1.0.0 */ utteranceId: string;}SynthesizeToFileResult
SynthesizeToFileResult파일로 합성 결과
export interface SynthesizeToFileResult { /** * The file path where audio was saved. * * @since 1.0.0 */ filePath: string;
/** * Unique identifier for this utterance. * * @since 1.0.0 */ utteranceId: string;}VoiceInfo
VoiceInfo음성 정보
export interface VoiceInfo { /** * Unique voice identifier. * * @since 1.0.0 */ id: string;
/** * Display name of the voice. * * @since 1.0.0 */ name: string;
/** * BCP-47 language code. * * @since 1.0.0 */ language: string;
/** * Gender of the voice (iOS only). * * @since 1.0.0 */ gender?: 'male' | 'female' | 'neutral';
/** * Whether this voice requires a network connection. * * @since 1.0.0 */ isNetworkConnectionRequired?: boolean;
/** * Whether this is the default voice (Web only). * * @since 1.0.0 */ default?: boolean;}IsLanguageAvailableOptions
언어 사용 가능 옵션언어 사용 가능 여부를 확인하는 옵션입니다.
export interface IsLanguageAvailableOptions { /** * The BCP-47 language code to check. * * @since 1.0.0 */ language: string;}IsVoiceAvailableOptions
음성 사용 가능 옵션음성 사용 가능 여부를 확인하는 옵션입니다.
export interface IsVoiceAvailableOptions { /** * The voice ID to check. * * @since 1.0.0 */ voiceId: string;}ActivateAudioSessionOptions
오디오 세션 활성화 옵션 (iOS 전용)오디오 세션을 활성화하는 옵션입니다 (iOS 전용).
export interface ActivateAudioSessionOptions { /** * The audio session category. * - 'Ambient': Mixes with other audio * - 'Playback': Stops other audio * * @since 1.0.0 */ category: 'Ambient' | 'Playback';}UtteranceEvent
발화 이벤트발화가 시작되거나 끝날 때 발생하는 이벤트입니다.
export interface UtteranceEvent { /** * The utterance identifier. * * @since 1.0.0 */ utteranceId: string;}BoundaryEvent
Section titled “BoundaryEvent”단어 경계에서 발생하는 이벤트.
export interface BoundaryEvent { /** * The utterance identifier. * * @since 1.0.0 */ utteranceId: string;
/** * The character index in the text. * * @since 1.0.0 */ charIndex: number;
/** * The character length of the current word. * * @since 1.0.0 */ charLength?: number;}ErrorEvent
Section titled “ErrorEvent”합성 오류 시 발생하는 이벤트.
export interface ErrorEvent { /** * The utterance identifier. * * @since 1.0.0 */ utteranceId: string;
/** * The error message. * * @since 1.0.0 */ error: string;}이 페이지는 플러그인의 src/definitions.ts. upstream의 공공 API이 변경될 때 다시 동기화할 수 있습니다.
Getting Started에서 계속
Section titled “Getting Started에서 계속”Capgo를 사용 중이라면 Getting Started 대시보드와 API 연산을 계획하고 연결하려면 Capacitor를 사용하여 @capgo/capacitor-speech-synthesis Capacitor를 사용하여 @capgo/capacitor-speech-synthesis API 개요 API Overview Capgo를 사용하여 구현 세부 정보를 확인하려면 Capgo를 사용하여 구현 세부 정보를 확인하려면 API Keys for the implementation detail in API Keys, and Capgo를 사용하여 장치 __CAPGO_KEEP_0__의 구현 세부 사항입니다.