Spaces:
Sleeping
Sleeping
File size: 914 Bytes
862aa2b 11152bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
DEEPGRAM_API_KEY = "599cc2f77feae2f13b61c735c2126d562664aa43"
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 |