Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
tcm390 committed Jan 1, 2025
1 parent c984a1e commit 37ffc83
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions packages/plugin-node/src/services/transcription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,29 @@ export class TranscriptionService
async initialize(_runtime: IAgentRuntime): Promise<void> {
this.runtime = _runtime;

let transcriptionProvider = TranscriptionProvider.Local;

switch (this.runtime.character.settings.transcription) {
case TranscriptionProvider.Deepgram:
case TranscriptionProvider.Deepgram: {
const deepgramKey = this.runtime.getSetting("DEEPGRAM_API_KEY");
if (deepgramKey) {
this.deepgram = createClient(deepgramKey);
this.transcriptionProvider = TranscriptionProvider.Deepgram;
} else {
this.transcriptionProvider = TranscriptionProvider.Local; // fall back to local transcription
transcriptionProvider = TranscriptionProvider.Deepgram;
}
break;
case TranscriptionProvider.OpenAI:
}
case TranscriptionProvider.OpenAI: {
const openAIKey = this.runtime.getSetting("OPENAI_API_KEY");
if (openAIKey) {
this.openai = new OpenAI({
apiKey: this.runtime.getSetting("OPENAI_API_KEY"),
apiKey: openAIKey,
});
this.transcriptionProvider = TranscriptionProvider.OpenAI;
} else {
this.transcriptionProvider = TranscriptionProvider.Local; // fall back to local transcription
transcriptionProvider = TranscriptionProvider.OpenAI;
}
break;
default:
this.transcriptionProvider = TranscriptionProvider.Local;
break;
}
}
this.transcriptionProvider = transcriptionProvider;
}

constructor() {
Expand Down

0 comments on commit 37ffc83

Please sign in to comment.