> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # Murf Mastra の Murf Voice 実装は、Murf の AI Voice サービスを使用した Text-to-Speech(TTS)機能を提供します。さまざまな言語の複数の Voice をサポートします。 ## 使用例 ```typescript import { MurfVoice } from '@mastra/voice-murf' // Initialize with default configuration (uses MURF_API_KEY environment variable) const voice = new MurfVoice() // Initialize with custom configuration const voice = new MurfVoice({ speechModel: { name: 'GEN2', apiKey: 'your-api-key', properties: { format: 'MP3', rate: 1.0, pitch: 1.0, sampleRate: 48000, channelType: 'STEREO', }, }, speaker: 'en-US-cooper', }) // Text-to-Speech with default settings const audioStream = await voice.speak('Hello, world!') // Text-to-Speech with custom properties const audioStream = await voice.speak('Hello, world!', { speaker: 'en-UK-hazel', properties: { format: 'WAV', rate: 1.2, style: 'casual', }, }) // Get available voices const voices = await voice.getSpeakers() ``` ## コンストラクターパラメーター **speechModel** (`MurfConfig`): Text-to-Speech 機能の設定 (Default: `{ name: 'GEN2' }`) **speechModel.name** (`'GEN1' | 'GEN2'`): 使用する Murf モデルの世代 **speechModel.apiKey** (`string`): Murf API キー。未指定の場合は MURF\_API\_KEY 環境変数を使用します **speechModel.properties** (`object`): すべての音声合成リクエストに使用するデフォルトプロパティ **speechModel.properties.style** (`string`): Voice の発話スタイル **speechModel.properties.rate** (`number`): 発話速度の倍率 **speechModel.properties.pitch** (`number`): Voice のピッチ調整 **speechModel.properties.sampleRate** (`8000 | 24000 | 44100 | 48000`): 音声サンプルレート(Hz) **speechModel.properties.format** (`'MP3' | 'WAV' | 'FLAC' | 'ALAW' | 'ULAW'`): 出力音声形式 **speechModel.properties.channelType** (`'STEREO' | 'MONO'`): 音声チャンネル設定 **speechModel.properties.pronunciationDictionary** (`Record`): カスタム発音のマッピング **speechModel.properties.encodeAsBase64** (`boolean`): 音声を base64 としてエンコードするかどうか **speechModel.properties.variation** (`number`): Voice のバリエーションパラメーター **speechModel.properties.audioDuration** (`number`): 目標の音声時間(秒) **speechModel.properties.multiNativeLocale** (`string`): 多言語サポートのロケール **speaker** (`string`): Text-to-Speech に使用するデフォルトの Voice ID (Default: `'en-UK-hazel'`) ## メソッド ### `speak()` Murf API を使用してテキストを音声に変換します。 **input** (`string | NodeJS.ReadableStream`): 音声に変換するテキスト。ストリームを指定した場合は、先にテキストへ変換されます。 **options** (`object`): 音声合成オプション **options.speaker** (`string`): このリクエストでデフォルトの Speaker を上書きします **options.properties** (`object`): このリクエストでデフォルトの音声プロパティを上書きします 戻り値:`Promise` ### `getSpeakers()` 使用可能な Voice オプションの配列を返します。各要素には次の値が含まれます。 **voiceId** (`string`): Voice の一意な識別子 **name** (`string`): Voice の表示名 **language** (`string`): Voice の言語コード **gender** (`string`): Voice の性別 ### `listen()` このメソッドは Murf でサポートされておらず、エラーをスローします。Murf は Speech-to-Text 機能を提供しません。 ## 重要な注意事項 1. Murf API キーが必要です。`MURF_API_KEY` 環境変数で設定するか、コンストラクターに渡してください。 2. このサービスは、デフォルトのモデルバージョンとして GEN2 を使用します。 3. 音声プロパティはコンストラクターで設定し、リクエストごとに上書きできます。 4. このサービスは、形式、サンプルレート、チャンネルタイプなどのプロパティを通じて幅広い音声カスタマイズをサポートします。 5. Speech-to-Text 機能はサポートされていません。