使用中:@capgo/capacitor-speech-synthesis
音声合成プラグイン
インストール
bun add @capgo/capacitor-speech-synthesis
bunx cap sync
このプラグインが公開するもの
speak- 指定されたオプションで与えられたテキストを話します。発話は音声キューに追加されます。synthesizeToFile- Android/iOS でのみ、テキストから音声を合成します。音声ファイルの保存先のパスを返します。cancel- キュー内のすべての発話をキャンセルし、現在の音声を停止します。pause- 音声の発話を即時停止します。
使用例
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
音声合成をオーディオファイルに合成し (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
すべてのキューされた発話をキャンセルし、現在の発話を停止します。
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.cancel();
pause
発話を即時停止します。
import { SpeechSynthesis } from '@capgo/capacitor-speech-synthesis';
await SpeechSynthesis.pause();
完全なリファレンス
- GitHub: https://github.com/Cap-go/capacitor-speech-synthesis/
- ドキュメント: /docs/plugins/speech-synthesis/
capgoを使用して、@capgo/capacitor-speech-synthesisを継続してください。
__CAPGO_KEEP_0__を使用している場合 capgo/capacitor-speech-synthesisを使用して、ネイティブプラグインの作業を計画する場合、@capgo/capacitor-speech-synthesisと接続してください。 __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-speech-synthesisを使用している場合 Cloudflareを使用して、@capgo/capacitor-speech-synthesisを接続してください。 実装詳細については @capgo/capacitor-speech-synthesis に Getting Started 実装詳細については Getting Started に Capgo プラグイン ディレクトリ 実装詳細については Capgo プラグイン ディレクトリ に Capacitor プラグイン ( Capgo によって提供) 実装詳細については Capacitor プラグイン ( Capgo によって提供) に プラグインの追加または更新 実装詳細については プラグインの追加または更新 に