Speechify
Mastra 中的 Speechify 语音实现通过 Speechify 的 API 提供文本转语音功能。
🌐 The Speechify voice implementation in Mastra provides text-to-speech capabilities using Speechify's API.
使用示例Direct link to 使用示例
🌐 Usage Example
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-english",
apiKey: "your-api-key",
},
speaker: "george", // Default voice
});
// Convert text to speech
const audioStream = await voice.speak("Hello, world!", {
speaker: "henry", // Override default voice
});
构造函数参数Direct link to 构造函数参数
🌐 Constructor Parameters
speechModel?:
SpeechifyConfig
= { name: 'simba-english' }
Configuration for text-to-speech functionality
speaker?:
SpeechifyVoiceId
= 'george'
Default voice ID to use for speech synthesis
SpeechifyConfigDirect link to SpeechifyConfig
name?:
VoiceModelName
= 'simba-english'
The Speechify model to use
apiKey?:
string
Speechify API key. Falls back to SPEECHIFY_API_KEY environment variable
方法Direct link to 方法
🌐 Methods
speak()Direct link to speak()
使用配置的语音模型和声音将文本转换为语音。
🌐 Converts text to speech using the configured speech model and voice.
input:
string | NodeJS.ReadableStream
Text to convert to speech. If a stream is provided, it will be converted to text first.
options.speaker?:
string
= Constructor's speaker value
Override the default speaker for this request
options.model?:
VoiceModelName
= Constructor's model value
Override the default model for this request
返回:Promise<NodeJS.ReadableStream>
🌐 Returns: Promise<NodeJS.ReadableStream>
getSpeakers()Direct link to getSpeakers()
返回一个可用语音选项的数组,每个节点包含:
🌐 Returns an array of available voice options, where each node contains:
voiceId:
string
Unique identifier for the voice
name:
string
Display name of the voice
language:
string
Language code for the voice
gender:
string
Gender of the voice
listen()Direct link to listen()
该方法不被 Speechify 支持,会导致错误。Speechify 不提供语音转文本功能。
🌐 This method is not supported by Speechify and will throw an error. Speechify does not provide speech-to-text functionality.
注意Direct link to 注意
🌐 Notes
- Speechify 需要 API 密钥进行身份验证
- 默认模型是 'simba-english'
- 不支持语音转文字功能
- 可以通过 speak() 方法的 options 参数传递额外的音频流选项