language-learning-app/api/app/outbound/deepgram/deepgram_client.py

22 lines
655 B
Python
Raw Normal View History

2026-03-27 07:54:00 +00:00
import asyncio
from deepgram import (
AsyncDeepgramClient,
)
class LocalDeepgramClient:
def __init__(self, api_key: str):
self.deepgram_client = AsyncDeepgramClient(api_key=api_key)
async def transcribe_local_file(self, local_file_path: str, language_code: str):
with open(local_file_path, "rb") as audio_file:
response = await self.deepgram_client.listen.v1.media.transcribe_file(
request=audio_file.read(),
model="nova-3",
language=language_code,
utterances=True,
smart_format=True,
)
return response.results