Erginous_project / transcription.py
jobanpreet123's picture
Upload 3 files
11152bc verified
raw
history blame
914 Bytes
DEEPGRAM_API_KEY = "133b94c2e717ad8749463de64418ba5fb78efcb3"
from deepgram import (
DeepgramClient,
PrerecordedOptions,
FileSource
)
import httpx
def deepgram(buffer_data,language):
# STEP 1 Create a Deepgram client using the API key
deepgram = DeepgramClient(DEEPGRAM_API_KEY)
payload: FileSource = {
"buffer": buffer_data,
}
#STEP 2: Configure Deepgram options for audio analysis
options = PrerecordedOptions(
model="nova-2",
smart_format=True,
language=language,
diarize=True,
)
myTimeout = httpx.Timeout(300, connect=10.0)
# STEP 3: Call the transcribe_file method with the text payload and options
response = deepgram.listen.prerecorded.v("1").transcribe_file(payload, options,timeout=myTimeout)
text=response['results']['channels'][0]['alternatives'][0]['paragraphs']['transcript']
return text