Getting Started
このプラグインのインストール手順とマークダウンガイドの全体を含むセットアップコマンドをコピーします。
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.
Install
インストール、同期、ソースマークダウンガイドを含みます。AI-Assisted セットアップを使用してプラグインをインストールできます。次のコマンドを使用して、Capgo スキルをAIツールに追加します。
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 syncインポート
__CAPGO_KEEP_0__の概要import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';APIの概要
APIガイドspeak
「話す」speakする
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”
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 “cancel”
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.cancel();pause
すべてのキューをキャンセルSection titled “pause”
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.pause();resume
セクション「再開」再生が一時停止されました。
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.resume();isSpeaking
セクション「発話中」発話合成が現在発話しているかどうかを確認します。
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { isSpeaking } = await SpeechSynthesis.isSpeaking();console.log('Is speaking:', isSpeaking);isAvailable
セクション「利用可能」デバイス上で発話合成が利用可能かどうかを確認します。
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { isAvailable } = await SpeechSynthesis.isAvailable();if (isAvailable) { console.log('Speech synthesis is available');}getVoices
セクション「声の取得」利用可能なすべての声の取得
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { voices } = await SpeechSynthesis.getVoices();voices.forEach(voice => { console.log(`${voice.name} (${voice.language})`);});getLanguages
言語を取得すべての利用可能な言語を取得します。
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { languages } = await SpeechSynthesis.getLanguages();console.log('Available languages:', languages);isLanguageAvailable
言語が利用可能かどうか特定の言語が利用可能かどうかを確認します。
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
const { isAvailable } = await SpeechSynthesis.isLanguageAvailable({ language: 'es-ES'});console.log('Spanish available:', isAvailable);isVoiceAvailable
「isVoiceAvailable」特定の声が利用可能かどうかを確認します。
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
セクションのタイトル “activateAudioSession”iOS でのみ、特定のカテゴリでオーディオ セッションを有効にします。
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.activateAudioSession({ category: 'Playback'});deactivateAudioSession
セクションのタイトル “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
「ファイルに合成する結果」ファイルに合成した結果。
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
「声の情報」声の情報。
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 限定)。
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
「境界イベント」をタイトルにしたセクション。単語の境界で発生するイベント。
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
「エラーアイベント」をタイトルにしたセクション。シンセシスのエラー発生時発行されるイベント。
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 がアップストリームで変更された場合。
続きます
続きますあなたが使用している はじめから 計画用ダッシュボードと API の運用に使用している場合、@API/__CAPGO_KEEP_1__-speech-synthesis を接続してください。 @capgo/capacitor-speech-synthesis native capability in @capgo/capacitor-speech-synthesis について API の概要 API の実装詳細について 導入 __CAPGO_KEEP_0__ の実装詳細について API のキー API の実装詳細について、 デバイス __CAPGO_KEEP_0__ の実装詳細について