Speechify
Mastra の Speechify Voice 実装は、Speechify API を使用した Text-to-Speech 機能を提供します。
使用例使用例への直接リンク
import { SpeechifyVoice } from '@mastra/voice-speechify'
// Initialize with default configuration (uses SPEECHIFY_API_KEY environment variable)
const voice = new SpeechifyVoice()
// Initialize with custom configuration
const voice = new SpeechifyVoice({
speechModel: {
name: 'simba-3.2',
apiKey: 'your-api-key',
},
speaker: 'harper_32', // Default voice (simba-3.2 serves the curated Simba 3 voices only)
})
// Convert text to speech
const audioStream = await voice.speak('Hello, world!', {
speaker: 'imogen_32', // Override default voice
})
コンストラクターパラメーターコンストラクターパラメーターへの直接リンク
speechModel?:
SpeechifyConfig
= { name: 'simba-english' }
Text-to-Speech 機能の設定
SpeechifyConfig
name?:
SpeechifyModel
使用する Speechify モデル('simba-3.2'、'simba-3.0'、'simba-english'、'simba-multilingual' のいずれか)
apiKey?:
string
Speechify API キー。未指定の場合は SPEECHIFY_API_KEY 環境変数を使用します
speaker?:
SpeechifyVoiceId
= 'harper_32' for Simba 3 models, otherwise 'george'
音声合成に使用するデフォルトの Voice ID。Simba 3 モデルでは厳選された Voice セット(harper_32、imogen_32 など)だけを利用できます。従来のカタログ Voice(george、henry など)は simba-english と simba-multilingual で使用できます
メソッドメソッドへの直接リンク
speak()speakへの直接リンク
設定された音声モデルと Voice を使用してテキストを音声に変換します。
input:
string | NodeJS.ReadableStream
音声に変換するテキスト。ストリームを指定した場合は、先にテキストへ変換されます。
options?:
Options
設定オプション。
Options
speaker?:
string
このリクエストでデフォルトの Speaker を上書きします
model?:
SpeechifyModel
このリクエストでデフォルトモデルを上書きします
戻り値:Promise<NodeJS.ReadableStream>
getSpeakers()getspeakersへの直接リンク
使用可能な Voice オプションの配列を返します。各要素には次の値が含まれます。
voiceId:
string
Voice の一意な識別子
name:
string
Voice の表示名
language:
string
Voice の言語コード
gender:
string
Voice の性別
listen()listenへの直接リンク
このメソッドは Speechify でサポートされておらず、エラーをスローします。Speechify は Speech-to-Text 機能を提供しません。
注意事項注意事項への直接リンク
- Speechify の認証には API キーが必要です
- デフォルトモデルは 'simba-english' です
- 'simba-3.2' は、最小のレイテンシーと最も豊かな表現力を備えた Speechify の最新ストリーミングモデルで、英語向けの推奨モデルです
- 現在、'simba-3.2' と 'simba-3.0' は英語だけに対応しています。英語以外または複数言語が混在する入力には 'simba-multilingual' を使用してください
- 'simba-3.2' と 'simba-3.0' で利用できるのは、厳選された Voice セット('beatrice_32'、'dominic_32'、'edmund_32'、'geffen_32'、'harper_32'、'hugh_32'、'imogen_32'、'wyatt_32')だけです。'george' など従来のカタログ Voice をこれらのモデルで使用するとエラーになります
- デフォルトの Speaker は設定されたモデルに従い、Simba 3 モデルでは 'harper_32'、それ以外では 'george' です
- Speech-to-Text 機能はサポートされていません
- speak() メソッドの options パラメーターで、追加の音声ストリームオプションを渡せます