メインコンテンツへ移動

Deepgram

Mastra の Deepgram Voice 実装は、Deepgram API を使用した Text-to-Speech(TTS)および Speech-to-Text(STT)機能を提供します。複数の Voice モデルと言語をサポートし、音声合成と文字起こしの両方に設定可能なオプションがあります。

使用例
使用例への直接リンク

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)

コンストラクターパラメーター
コンストラクターパラメーターへの直接リンク

speechModel?:

DeepgramVoiceConfig
= { name: 'aura' }
Text-to-Speech 機能の設定。
DeepgramVoiceConfig

name?:

DeepgramModel
使用する Deepgram モデル

apiKey?:

string
Deepgram API キー。未指定の場合は DEEPGRAM_API_KEY 環境変数を使用します

properties?:

Record<string, any>
Deepgram API に渡す追加プロパティ

language?:

string
モデルの言語コード

listeningModel?:

DeepgramVoiceConfig
= { name: 'nova' }
Speech-to-Text 機能の設定。
DeepgramVoiceConfig

name?:

DeepgramModel
使用する Deepgram モデル

apiKey?:

string
Deepgram API キー。未指定の場合は DEEPGRAM_API_KEY 環境変数を使用します

properties?:

Record<string, any>
Deepgram API に渡す追加プロパティ

language?:

string
モデルの言語コード

speaker?:

DeepgramVoiceId
= 'asteria-en'
Text-to-Speech に使用するデフォルトの Voice

メソッド
メソッドへの直接リンク

speak()
speakへの直接リンク

設定された音声モデルと Voice を使用してテキストを音声に変換します。

input:

string | NodeJS.ReadableStream
音声に変換するテキスト。ストリームを指定した場合は、先にテキストへ変換されます。

options?:

object
音声合成の追加オプション
object

speaker?:

string
このリクエストでデフォルトの Speaker を上書きします

戻り値:Promise<NodeJS.ReadableStream>

listen()
listenへの直接リンク

設定されたリスニングモデルを使用して音声をテキストに変換します。

audioStream:

NodeJS.ReadableStream
文字起こしする音声ストリーム

options?:

object
Deepgram API に渡す追加オプション

戻り値:Promise<string>

getSpeakers()
getspeakersへの直接リンク

使用可能な Voice オプションの一覧を返します。

voiceId:

string
Voice の一意な識別子