Deepgram
Mastra 中的 Deepgram 语音实现提供了使用 Deepgram API 的文本转语音 (TTS) 和语音转文本 (STT) 功能。它支持多种语音模型和语言,并且可以配置语音合成和转录的各种选项。
🌐 The Deepgram voice implementation in Mastra provides text-to-speech (TTS) and speech-to-text (STT) capabilities using Deepgram's API. It supports multiple voice models and languages, with configurable options for both speech synthesis and transcription.
使用示例Direct link to 使用示例
🌐 Usage Example
import { DeepgramVoice } from "@mastra/voice-deepgram";
// Initialize with default configuration (uses DEEPGRAM_API_KEY environment variable)
const voice = new DeepgramVoice();
// Initialize with custom configuration
const voice = new DeepgramVoice({
speechModel: {
name: "aura",
apiKey: "your-api-key",
},
listeningModel: {
name: "nova-2",
apiKey: "your-api-key",
},
speaker: "asteria-en",
});
// Text-to-Speech
const audioStream = await voice.speak("Hello, world!");
// Speech-to-Text
const transcript = await voice.listen(audioStream);
构造函数参数Direct link to 构造函数参数
🌐 Constructor Parameters
speechModel?:
listeningModel?:
speaker?:
DeepgramVoiceConfigDirect link to DeepgramVoiceConfig
name?:
apiKey?:
properties?:
language?:
方法Direct link to 方法
🌐 Methods
speak()Direct link to speak()
使用配置的语音模型和声音将文本转换为语音。
🌐 Converts text to speech using the configured speech model and voice.
input:
options?:
options.speaker?:
返回:Promise<NodeJS.ReadableStream>
🌐 Returns: Promise<NodeJS.ReadableStream>
listen()Direct link to listen()
使用配置的监听模型将语音转换为文本。
🌐 Converts speech to text using the configured listening model.
audioStream:
options?:
返回:Promise<string>
🌐 Returns: Promise<string>
getSpeakers()Direct link to getSpeakers()
返回可用语音选项的列表。
🌐 Returns a list of available voice options.