22 lines
655 B
Python
22 lines
655 B
Python
|
|
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
|
||
|
|
|