Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: deepgram live transcription in screenpipe cloud (#1266)

Ezra Ellette940ab300455b
diff --git a/screenpipe-actions/ai-proxy/src/index.ts b/screenpipe-actions/ai-proxy/src/index.ts
index b7d17ae61..e8a0aa0f0 100644
--- a/screenpipe-actions/ai-proxy/src/index.ts
+++ b/screenpipe-actions/ai-proxy/src/index.ts
@@ -3,7 +3,7 @@ import { verifyToken } from '@clerk/backend';
import { createProvider } from './providers';
import { Env, RequestBody } from './types';
import * as Sentry from '@sentry/cloudflare';
-import { Deepgram, LiveClient } from '@deepgram/sdk';
+import { Deepgram, DeepgramClient, LiveClient } from '@deepgram/sdk';
import { createClient, LiveTranscriptionEvents } from '@deepgram/sdk';
// Add cache for subscription status
@@ -205,8 +205,26 @@ async function handleWebSocketUpgrade(request: Request, env: Env): Promise<Respo
url.searchParams.set(key, value);
}
- const deepgram = createClient(env.DEEPGRAM_API_KEY);
- const deepgramSocket = deepgram.listen.live({}, url.toString());
+ let deepgram: DeepgramClient | null = null;
+ try {
+ deepgram = createClient(env.DEEPGRAM_API_KEY);
+ } catch (error: any) {
+ console.error('Error creating Deepgram client:', error);
+ return new Response(`Deepgram client creation failed: ${error.message}`, { status: 500 });
+ }
+
+ if (!deepgram) {
+ return new Response('Deepgram client creation failed', { status: 500 });
+ }
+
+ let deepgramSocket: LiveClient;
+
+ try {
+ deepgramSocket = deepgram.listen.live({}, url.toString());
+ } catch (error: any) {
+ console.error('Error creating Deepgram socket:', error);
+ return new Response(`Deepgram socket creation failed: ${error.message}`, { status: 500 });
+ }
deepgramSocket.on(LiveTranscriptionEvents.Open, () => {
server.send(
diff --git a/screenpipe-audio/Cargo.toml b/screenpipe-audio/Cargo.toml
index 0c8f0b099..d9cb639a0 100644
--- a/screenpipe-audio/Cargo.toml
+++ b/screenpipe-audio/Cargo.toml
@@ -78,7 +78,7 @@ ort = "=2.0.0-rc.6"
knf-rs = { git = "https://github.com/Neptune650/knf-rs.git", branch = "main" }
ort-sys = "=2.0.0-rc.8"
futures = "0.3.31"
-deepgram = "0.6.4"
+deepgram = { git = "https://github.com/EzraEllette/deepgram-rust-sdk.git" }
bytes = { version = "1.9.0", features = ["serde"] }
[target.'cfg(target_os = "windows")'.dependencies]