> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # Mistral MistralVoice クラスは、Mistral の Voxtral 音声モデルを使用した Text-to-Speech および Speech-to-Text 機能を提供します。バッファリングとストリーミングによる TTS、ダイアライゼーション付きのバッチ文字起こし、参照音声による Voice クローニングをサポートします。 ## 使用例 ```typescript import { MistralVoice } from '@mastra/voice-mistral' const voice = new MistralVoice() // Text-to-speech const audioStream = await voice.speak('Hello, how can I help you?', { responseFormat: 'mp3', }) // Speech-to-text const text = await voice.listen(audioStream, { language: 'en', }) // List available voices const speakers = await voice.getSpeakers() ``` ```typescript import { MistralVoice } from '@mastra/voice-mistral' // Initialize with specific configuration const voice = new MistralVoice({ speechModel: { name: 'voxtral-mini-tts-2603', apiKey: 'your-mistral-api-key', }, listeningModel: { name: 'voxtral-mini-latest', apiKey: 'your-mistral-api-key', }, speaker: 'en_paul_neutral', }) ``` ## コンストラクターパラメーター **speechModel** (`MistralModelConfig`): Text-to-Speech 合成の設定。 (Default: `{ name: 'voxtral-mini-tts-2603' }`) **speechModel.name** (`string`): 音声合成に使用するモデル ID。 **speechModel.apiKey** (`string`): Mistral API キー。未指定の場合は MISTRAL\_API\_KEY 環境変数を使用します。 **listeningModel** (`MistralModelConfig`): Speech-to-Text 認識の設定。 (Default: `{ name: 'voxtral-mini-latest' }`) **listeningModel.name** (`string`): 文字起こしに使用するモデル ID。固定バージョンには 'voxtral-mini-2507' を使用します。 **listeningModel.apiKey** (`string`): Mistral API キー。未指定の場合は MISTRAL\_API\_KEY 環境変数を使用します。 **speaker** (`string`): 音声合成に使用するデフォルトの Voice ID。使用可能な ID は getSpeakers() で取得します。 (Default: `'en_paul_neutral'`) ## メソッド ### `speak(input, options?)` Mistral の Voxtral TTS モデルを使用してテキストを音声に変換します。バッファリング出力とストリーミング出力の両方をサポートします。 **input** (`string | NodeJS.ReadableStream`): 音声に変換するテキストまたはテキストストリーム。 **options** (`MistralSpeakOptions`): 設定オプション。 **options.speaker** (`string`): 使用する Voice ID。コンストラクターのデフォルト値を上書きします。 **options.responseFormat** (`'pcm' | 'wav' | 'mp3' | 'flac' | 'opus'`): 音声出力形式。最小レイテンシーのストリーミングには 'pcm' を使用します。 **options.refAudio** (`string`): 一度限りの Voice クローニングに使用する base64 エンコード済み参照音声(最低2~3秒)。 **options.model** (`string`): この呼び出しで音声モデルを上書きします。 **options.stream** (`boolean`): ストリーミング TTS を有効にします。到着した音声チャンクが順次ストリームに書き込まれます。 戻り値:`Promise` ### `listen(audioStream, options?)` Mistral の Voxtral 文字起こしモデルを使用して音声を文字起こしします。ダイアライゼーション、コンテキストバイアス、タイムスタンプの詳細レベルをサポートします。 **audioStream** (`NodeJS.ReadableStream`): 文字起こしする音声ストリーム。 **options** (`MistralListenOptions`): 設定オプション。 **options.language** (`string`): 言語コード(例:'en')。指定すると精度が向上します。 **options.diarize** (`boolean`): Speaker ダイアライゼーションを有効にします。 **options.contextBias** (`string[]`): 語彙を導く単語またはフレーズ。 **options.timestampGranularities** (`('segment' | 'word')[]`): 文字起こしセグメントのタイムスタンプ詳細レベル。 **options.filetype** (`string`): 入力ストリームの音声ファイル拡張子のヒント。 戻り値:`Promise` ### `getSpeakers()` Mistral Voices API から使用可能なプリセット Voice を取得します。各要素には次の値が含まれます。 **voiceId** (`string`): Voice の一意な識別子。 **name** (`string`): Voice の表示名。 **languages** (`string[]`): Voice がサポートする言語。 **gender** (`string | null`): Voice の性別。 ### `getListener()` `{ enabled: true }` を返します。 ## 注意事項 - API キーは、コンストラクターオプションまたは `MISTRAL_API_KEY` 環境変数で指定できます - TTS は9言語(英語、フランス語、スペイン語、ポルトガル語、イタリア語、オランダ語、ドイツ語、ヒンディー語、アラビア語)をサポートします - STT は13言語(英語、中国語、ヒンディー語、スペイン語、アラビア語、フランス語、ポルトガル語、ロシア語、ドイツ語、日本語、韓国語、イタリア語、オランダ語)をサポートします - 最良の結果を得るため、TTS の入力テキストは1リクエストあたり300語未満にしてください - STT は1リクエストあたり最大3時間の音声をサポートします - `refAudio` による Voice クローニングには、最低2~3秒の参照音声が必要です - `getSpeakers()` は UUID 識別子を持つプリセット Voice を返します。デフォルトの `en_paul_neutral` は TTS エンドポイントで使用できる名前付きエイリアスですが、この一覧には含まれません