Skip to content

__CAPGO_KEEP_1__

터미널 창
bun add @capgo/capacitor-speech-synthesis
bunx cap sync
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';

지정된 옵션과 함께 주어진 텍스트를 말합니다. 말하는 음성 큐에 음성 발화가 추가됩니다.

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

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

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

__CAPGO_KEEP_3__

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.cancel();

__CAPGO_KEEP_0__

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.pause();

__CAPGO_KEEP_6__

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.resume();

__CAPGO_KEEP_2__

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { isSpeaking } = await SpeechSynthesis.isSpeaking();
console.log('Is speaking:', isSpeaking);

isAvailable

__CAPGO_KEEP_1__

__CAPGO_KEEP_3__

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { isAvailable } = await SpeechSynthesis.isAvailable();
if (isAvailable) {
console.log('Speech synthesis is available');
}

__CAPGO_KEEP_4__

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__

__CAPGO_KEEP_5__

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { languages } = await SpeechSynthesis.getLanguages();
console.log('Available languages:', languages);

isLanguageAvailable

__CAPGO_KEEP_1__의 섹션

__CAPGO_KEEP_2__을 확인합니다.

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { isAvailable } = await SpeechSynthesis.isLanguageAvailable({
language: 'es-ES'
});
console.log('Spanish available:', isAvailable);

__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);

__CAPGO_KEEP_2__를 초기화합니다. (iOS 최적화). 이것은 첫 번째 음성 요청에 대한 지연 시간을 줄일 수 있습니다.

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.initialize();

activateAudioSession

__CAPGO_KEEP_1__의 섹션

__CAPGO_KEEP_2__를 활성화합니다 (iOS 전용).

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.activateAudioSession({
category: 'Playback'
});

복사

import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.deactivateAudioSession();

타입 참조

음성 옵션

음성 텍스트 결과

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

복사

음성 텍스트 결과 복사

export interface SpeakResult {
/**
* Unique identifier for this utterance.
*
* @since 1.0.0
*/
utteranceId: string;
}

파일로 합성 결과입니다.

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

음성에 대한 정보입니다.

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

언어 사용 가능성 확인 옵션입니다.

export interface IsLanguageAvailableOptions {
/**
* The BCP-47 language code to check.
*
* @since 1.0.0
*/
language: string;
}

음성 사용 가능성 확인 옵션입니다.

export interface IsVoiceAvailableOptions {
/**
* The voice ID to check.
*
* @since 1.0.0
*/
voiceId: string;
}

ActivateAudioSessionOptions

ActivateAudioSessionOptions

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

UtteranceEvent

발화 시작 또는 종료 시 발생하는 이벤트

export interface UtteranceEvent {
/**
* The utterance identifier.
*
* @since 1.0.0
*/
utteranceId: string;
}

BoundaryEvent

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

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공개 API이 업스트림에서 변경될 때 다시 싱크를 실행하세요.

Getting Started

Getting Started

이 플러그인을 사용하는 경우 Getting Started 계획 대시보드 및 API 작업을 위해 연결하세요. Using @capgo/capacitor-speech-synthesis Using @capgo/capacitor-speech-synthesis API 개요 API 개요에 대한 구현 세부 정보를 위해 소개 __CAPGO_KEEP_0__ 키에 대한 구현 세부 정보를 위해 API 키 및 for the implementation detail in API Keys, and __CAPGO_KEEP_0__ 기기에 대한 구현 세부 정보를 위해 수정 페이지