Skip to content

Commit 5f9602e

Browse files
authored
Add option to add deepgram tags. (#67)
1 parent 2757241 commit 5f9602e

6 files changed

Lines changed: 33 additions & 0 deletions

File tree

env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ OPENAI_TRANSCRIPTION_PROMPT="You will hear audio coming from one participant in
102102
# Default: false
103103
# DEEPGRAM_DIARIZE=false
104104

105+
# Custom tags for Deepgram requests (comma-separated list)
106+
# Tags can be used to categorize and filter requests in Deepgram analytics
107+
# Default: none
108+
# Example: DEEPGRAM_TAGS=production,voice-assistant,customer-support
109+
# DEEPGRAM_TAGS=
110+
105111
# ============================================
106112
# Server Configuration
107113
# ============================================

src/backends/DeepgramBackend.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ export class DeepgramBackend implements TranscriptionBackend {
9292
params.set('diarize', config.deepgram.diarize.toString());
9393
}
9494

95+
// Add tags if configured
96+
if (config.deepgram.tags && config.deepgram.tags.length > 0) {
97+
config.deepgram.tags.forEach((tag) => {
98+
params.append('tag', tag);
99+
});
100+
}
101+
95102
const deepgramUrl = `${DEEPGRAM_WS_BASE}?${params.toString()}`;
96103

97104
// Create WebSocket with Sec-WebSocket-Protocol for authentication

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const config = {
5757
punctuate: process.env.DEEPGRAM_PUNCTUATE === 'true',
5858
diarize: process.env.DEEPGRAM_DIARIZE === 'true',
5959
includeLanguage: process.env.DEEPGRAM_INCLUDE_LANGUAGE === 'true', // Default false
60+
tags: process.env.DEEPGRAM_TAGS ? process.env.DEEPGRAM_TAGS.split(',').map((t) => t.trim()).filter((t) => t) : [],
6061
},
6162

6263
server: {

test/unit/backends/DeepgramBackend.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ vi.mock('../../../src/config', () => ({
3434
punctuate: true,
3535
diarize: false,
3636
includeLanguage: false,
37+
tags: ['test-tag-1', 'test-tag-2'],
3738
},
3839
},
3940
}));
@@ -144,6 +145,22 @@ describe('DeepgramBackend', () => {
144145
expect(mockWsManager.mockWs.url).toContain('diarize=false');
145146
});
146147

148+
it('should include tags in URL if configured', async () => {
149+
const backend = new DeepgramBackend('test-tag', { id: 'participant-1' });
150+
const config: BackendConfig = {
151+
model: 'nova-2',
152+
language: null,
153+
prompt: undefined,
154+
};
155+
156+
const connectPromise = backend.connect(config);
157+
mockWsManager.mockWs.simulateOpen();
158+
await connectPromise;
159+
160+
expect(mockWsManager.mockWs.url).toContain('tag=test-tag-1');
161+
expect(mockWsManager.mockWs.url).toContain('tag=test-tag-2');
162+
});
163+
147164
it('should start KeepAlive timer on connection', async () => {
148165
const backend = new DeepgramBackend('test-tag', { id: 'participant-1' });
149166
const config: BackendConfig = {

worker/env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface Env {
3030
DEEPGRAM_INCLUDE_LANGUAGE?: string;
3131
DEEPGRAM_PUNCTUATE?: string;
3232
DEEPGRAM_ENCODING?: string;
33+
DEEPGRAM_TAGS?: string;
3334
PROVIDERS_PRIORITY?: string;
3435
FORCE_COMMIT_TIMEOUT?: string;
3536
DEBUG?: string;

worker/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export class TranscriberContainer extends Container<Env> {
6464
DEEPGRAM_INCLUDE_LANGUAGE: this.env.DEEPGRAM_INCLUDE_LANGUAGE || 'false',
6565
DEEPGRAM_PUNCTUATE: this.env.DEEPGRAM_PUNCTUATE || 'true',
6666
DEEPGRAM_ENCODING: this.env.DEEPGRAM_ENCODING || 'opus',
67+
DEEPGRAM_TAGS: this.env.DEEPGRAM_TAGS || '',
6768
PROVIDERS_PRIORITY: this.env.PROVIDERS_PRIORITY || 'openai',
6869
FORCE_COMMIT_TIMEOUT: this.env.FORCE_COMMIT_TIMEOUT || '2',
6970
DEBUG: this.env.DEBUG || 'true',

0 commit comments

Comments
 (0)