Skip to Content
リファレンス音声リファレンス: Deepgram Voice | 音声プロバイダー | Mastra ドキュメント

Deepgram

MastraにおけるDeepgramの音声実装は、DeepgramのAPIを利用してテキスト読み上げ(TTS)および音声認識(STT)機能を提供します。複数の音声モデルと言語に対応しており、音声合成と文字起こしの両方で設定可能なオプションが用意されています。

使用例

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' }
テキスト読み上げ機能のための設定。

listeningModel?:

DeepgramVoiceConfig
= { name: 'nova' }
音声認識機能のための設定。

speaker?:

DeepgramVoiceId
= 'asteria-en'
テキスト読み上げで使用するデフォルトの音声

DeepgramVoiceConfig

name?:

DeepgramModel
使用するDeepgramモデル

apiKey?:

string
Deepgram APIキー。指定がない場合はDEEPGRAM_API_KEY環境変数が使用されます

properties?:

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

language?:

string
モデルの言語コード

メソッド

speak()

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

input:

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

options?:

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

options.speaker?:

string
このリクエストのデフォルトスピーカーを上書きします

戻り値: Promise<NodeJS.ReadableStream>

listen()

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

audioStream:

NodeJS.ReadableStream
書き起こし対象の音声ストリーム

options?:

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

戻り値: Promise<string>

getSpeakers()

利用可能なボイスオプションの一覧を返します。

voiceId:

string
ボイスの一意な識別子