deepgram-core-workflow-b
Deepgramを使ったリアルタイムストリーミング文字起こしを実装できます。 ライブ文字起こし、音声インターフェース、リアルタイムオーディオ処理アプリケーションの構築時に活用できます。「deepgramストリーミング」「リアルタイム文字起こし」「ライブ文字起こし」「websocket文字起こし」「音声ストリーミング」といったフレーズでトリガーされます。
description の原文を見る
Implement real-time streaming transcription with Deepgram. Use when building live transcription, voice interfaces, or real-time audio processing applications. Trigger with phrases like "deepgram streaming", "real-time transcription", "live transcription", "websocket transcription", "voice streaming".
SKILL.md 本文
Deepgram Core Workflow B: リアルタイムストリーミング
概要
Deepgram の WebSocket API を使用してリアルタイムストリーミング文字起こしを実装し、ライブオーディオ処理を行います。
前提条件
deepgram-install-authセットアップの完了- WebSocket パターンの理解
- オーディオ入力ソース(マイクロフォンまたはストリーム)
手順
ステップ 1: WebSocket 接続の設定
Deepgram でライブ文字起こし接続を初期化します。
ステップ 2: ストリームオプションの設定
暫定結果、エンドポイント、言語オプションを設定します。
ステップ 3: イベントの処理
トランスクリプトイベントと接続ライフサイクルのハンドラを実装します。
ステップ 4: オーディオデータのストリーミング
WebSocket 接続にオーディオチャンクを送信します。
出力
- ライブ文字起こし WebSocket クライアント
- リアルタイム結果用のイベントハンドラ
- オーディオストリーミングパイプライン
- グレースフルな接続管理
エラーハンドリング
| エラー | 原因 | 解決方法 |
|---|---|---|
| Connection Closed | ネットワーク中断 | 自動再接続を実装 |
| Buffer Overflow | 過度なオーディオデータ | サンプルレートまたはチャンクサイズを削減 |
| No Transcripts | 無音オーディオ | オーディオレベルとフォーマットを確認 |
| High Latency | ネットワーク/処理遅延 | 暫定結果を使用 |
例
TypeScript WebSocket クライアント
// services/live-transcription.ts
import { createClient, LiveTranscriptionEvents } from '@deepgram/sdk';
export interface LiveTranscriptionOptions {
model?: 'nova-2' | 'nova' | 'enhanced' | 'base';
language?: string;
punctuate?: boolean;
interimResults?: boolean;
endpointing?: number;
vadEvents?: boolean;
}
export class LiveTranscriptionService {
private client;
private connection: any = null;
constructor(apiKey: string) {
this.client = createClient(apiKey);
}
async start(
options: LiveTranscriptionOptions = {},
handlers: {
onTranscript?: (transcript: string, isFinal: boolean) => void;
onError?: (error: Error) => void;
onClose?: () => void;
} = {}
): Promise<void> {
this.connection = this.client.listen.live({
model: options.model || 'nova-2',
language: options.language || 'en',
punctuate: options.punctuate ?? true,
interim_results: options.interimResults ?? true,
endpointing: options.endpointing ?? 300,
vad_events: options.vadEvents ?? true,
});
this.connection.on(LiveTranscriptionEvents.Open, () => {
console.log('Deepgram connection opened');
});
this.connection.on(LiveTranscriptionEvents.Transcript, (data: any) => {
const transcript = data.channel.alternatives[0].transcript;
const isFinal = data.is_final;
if (transcript && handlers.onTranscript) {
handlers.onTranscript(transcript, isFinal);
}
});
this.connection.on(LiveTranscriptionEvents.Error, (error: Error) => {
console.error('Deepgram error:', error);
handlers.onError?.(error);
});
this.connection.on(LiveTranscriptionEvents.Close, () => {
console.log('Deepgram connection closed');
handlers.onClose?.();
});
}
send(audioData: Buffer): void {
if (this.connection) {
this.connection.send(audioData);
}
}
async stop(): Promise<void> {
if (this.connection) {
this.connection.finish();
this.connection = null;
}
}
}
ブラウザマイク統合
// services/microphone.ts
import { LiveTranscriptionService } from './live-transcription';
export async function startMicrophoneTranscription(
onTranscript: (text: string, isFinal: boolean) => void
): Promise<{ stop: () => void }> {
const service = new LiveTranscriptionService(process.env.DEEPGRAM_API_KEY!);
// Get microphone access
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
// Create audio context and processor
const audioContext = new AudioContext({ sampleRate: 16000 });
const source = audioContext.createMediaStreamSource(stream);
const processor = audioContext.createScriptProcessor(4096, 1, 1);
// Start transcription
await service.start({
model: 'nova-2',
interimResults: true,
punctuate: true,
}, {
onTranscript,
onError: console.error,
});
// Process audio
processor.onaudioprocess = (event) => {
const inputData = event.inputBuffer.getChannelData(0);
const pcmData = new Int16Array(inputData.length);
for (let i = 0; i < inputData.length; i++) {
pcmData[i] = Math.max(-32768, Math.min(32767, inputData[i] * 32768));
}
service.send(Buffer.from(pcmData.buffer));
};
source.connect(processor);
processor.connect(audioContext.destination);
return {
stop: () => {
processor.disconnect();
source.disconnect();
stream.getTracks().forEach(track => track.stop());
service.stop();
}
};
}
Node.js によるオーディオファイルストリーミング
// stream-file.ts
import { createReadStream } from 'fs';
import { LiveTranscriptionService } from './services/live-transcription';
async function streamAudioFile(filePath: string) {
const service = new LiveTranscriptionService(process.env.DEEPGRAM_API_KEY!);
const finalTranscripts: string[] = [];
await service.start({
model: 'nova-2',
punctuate: true,
interimResults: false,
}, {
onTranscript: (transcript, isFinal) => {
if (isFinal) {
finalTranscripts.push(transcript);
console.log('Final:', transcript);
}
},
onClose: () => {
console.log('Complete transcript:', finalTranscripts.join(' '));
},
});
// Stream file in chunks
const stream = createReadStream(filePath, { highWaterMark: 4096 });
for await (const chunk of stream) {
service.send(chunk);
// Pace the streaming to match real-time
await new Promise(resolve => setTimeout(resolve, 100));
}
await service.stop();
}
Python ストリーミング例
# services/live_transcription.py
from deepgram import DeepgramClient, LiveTranscriptionEvents, LiveOptions
import asyncio
class LiveTranscriptionService:
def __init__(self, api_key: str):
self.client = DeepgramClient(api_key)
self.connection = None
self.transcripts = []
async def start(self, on_transcript=None):
self.connection = self.client.listen.asynclive.v("1")
async def on_message(self, result, **kwargs):
transcript = result.channel.alternatives[0].transcript
if transcript and on_transcript:
on_transcript(transcript, result.is_final)
async def on_error(self, error, **kwargs):
print(f"Error: {error}")
self.connection.on(LiveTranscriptionEvents.Transcript, on_message)
self.connection.on(LiveTranscriptionEvents.Error, on_error)
options = LiveOptions(
model="nova-2",
language="en",
punctuate=True,
interim_results=True,
)
await self.connection.start(options)
def send(self, audio_data: bytes):
if self.connection:
self.connection.send(audio_data)
async def stop(self):
if self.connection:
await self.connection.finish()
自動再接続パターン
// services/resilient-live.ts
export class ResilientLiveTranscription {
private service: LiveTranscriptionService;
private reconnectAttempts = 0;
private maxReconnectAttempts = 5;
async connect(options: LiveTranscriptionOptions) {
try {
await this.service.start(options, {
onClose: () => this.handleDisconnect(options),
onError: (err) => console.error('Stream error:', err),
});
this.reconnectAttempts = 0;
} catch (error) {
await this.handleDisconnect(options);
}
}
private async handleDisconnect(options: LiveTranscriptionOptions) {
if (this.reconnectAttempts < this.maxReconnectAttempts) {
this.reconnectAttempts++;
const delay = Math.pow(2, this.reconnectAttempts) * 1000;
console.log(`Reconnecting in ${delay}ms...`);
await new Promise(r => setTimeout(r, delay));
await this.connect(options);
}
}
}
リソース
次のステップ
deepgram-common-errors に進んでエラーハンドリングパターンを確認します。
ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- Brmbobo
- リポジトリ
- Brmbobo/Web2podcast
- ライセンス
- MIT
- 最終更新
- 2026/1/26
Source: https://github.com/Brmbobo/Web2podcast / ライセンス: MIT
関連スキル
listenhub
あらゆることを説明できます。アイデアをポッドキャスト、解説動画、または音声ナレーションに変換します。 ユーザーが「ポッドキャストを作りたい」「解説動画を作成したい」「これを読み上げてほしい」「画像を生成したい」、または知識を音声・映像形式で共有したいときに使用します。トピックの説明、YouTubeリンク、記事URL、プレーンテキスト、画像プロンプトに対応しています。
best-youtube-video-editor
ClawHub上の「best-youtube-video-editor」スキルは、YouTube クリエイターのコンテンツ制作を革新します。タイムラインや複雑なソフトウェアを必要とせず、会話形式のAI駆動型ビデオ編集が可能です。無音部分のカット、チャプターマーカーの追加、字幕の挿入、ペーシングの調整、エクスポートの最適化——すべてが自然言語の指示で実現します。初回使用時には NemoVideo API を通じて認証情報を自動設定するため、有効化後数秒で編集を開始できます。YouTuber、教育関係者、ポッドキャスター、ブランドチャネル向けに開発され、品質を損なわず高速な納期対応が必要な方に最適です。mp4、mov、avi、webm、mkv 形式に対応しています。
video
ユーザーがAIツールやプログラマティックフレームワークを使用してビデオコンテンツを作成、生成、または制作したい場合に使用します。また、ユーザーが「ビデオ制作」「AIビデオ」「Remotion」「Hyperframes」「HeyGen」「Synthesia」「Veo」「Runway」「Kling」「Pika」「ビデオ生成」「AIアバター」「トーキングヘッドビデオ」「プログラマティックビデオ」「ビデオテンプレート」「解説ビデオ」「プロダクトデモビデオ」「ビデオパイプライン」または「ビデオを作ってほしい」と言及している場合にも使用します。ビデオ作成、生成、制作のワークフロー全般に対応できます。ビデオコンテンツの戦略や投稿内容については「social-content」を、有料ビデオ広告クリエイティブについては「ad-creative」をご参照ください。
clipify
ビデオから最も面白い瞬間を検出し、スタンドアロンクリップとしてカットできます。オプションで16:9から9:16へのリフォーマット(フェイスパンまたはスプリットスクリーン)に対応し、Opus風の単語ごとのキャプションを焼き込みます。ユーザーが「clipify」「このビデオからクリップをカットして」「これからショーツを作って」「面白い瞬間を見つけて」「9:16にリフレーミングして」「縦型クリップ」と言及したり、ビデオファイルパスを貼り付けてSNS対応のクリップを求める場合に使用します。
speech
ユーザーが音声生成、ナレーション、アクセシビリティ対応の読み上げ、音声プロンプト、またはOpenAI Audio APIによるバッチ音声生成をリクエストした場合に使用します。組み込みボイスを備えたバンドルCLI(`scripts/text_to_speech.py`)を実行でき、ライブ呼び出しには`OPENAI_API_KEY`が必要です。カスタムボイスの作成には対応していません。
depth-estimation
Depth Anything v2を使用したリアルタイム深度マップのプライバシー変換(CoreML + PyTorch対応) このスキルは、Depth Anything v2モデルを活用して、画像やビデオから取得した深度情報をリアルタイムで処理し、プライバシーを保護しながら変換します。CoreMLとPyTorchの両方に対応しており、エッジデバイスでの高速処理とクラウド環境での柔軟な運用が可能です。顔認識データのぼかしや背景の匿名化など、プライバシー関連の処理を効率的に実行できます。