Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,13 +27,16 @@ def whisper_openai_transcribe(audio_file):
|
|
27 |
return transcribed_text
|
28 |
|
29 |
def deepgram_transcribe(audio_file):
|
30 |
-
from deepgram import DeepgramClient, PrerecordedOptions
|
31 |
|
32 |
DEEPGRAM_API_KEY = "aeb38b43a17867c59928e6a103ac75c06d4e896d"
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
37 |
|
38 |
try:
|
39 |
deepgram = DeepgramClient(DEEPGRAM_API_KEY)
|
@@ -49,7 +52,7 @@ def deepgram_transcribe(audio_file):
|
|
49 |
diarize=True,
|
50 |
)
|
51 |
|
52 |
-
response = deepgram.listen.rest.v("1").
|
53 |
print(response.to_json(indent=4))
|
54 |
transcript = response['results']['channels'][0]['alternatives'][0]['transcript']
|
55 |
print(transcript)
|
|
|
27 |
return transcribed_text
|
28 |
|
29 |
def deepgram_transcribe(audio_file):
|
30 |
+
from deepgram import DeepgramClient, PrerecordedOptions, Filesource
|
31 |
|
32 |
DEEPGRAM_API_KEY = "aeb38b43a17867c59928e6a103ac75c06d4e896d"
|
33 |
|
34 |
+
with open(audio_file, "rb") as file:
|
35 |
+
buffer_data = file.read()
|
36 |
+
|
37 |
+
payload: FileSource = {
|
38 |
+
"buffer": buffer_data,
|
39 |
+
}
|
40 |
|
41 |
try:
|
42 |
deepgram = DeepgramClient(DEEPGRAM_API_KEY)
|
|
|
52 |
diarize=True,
|
53 |
)
|
54 |
|
55 |
+
response = deepgram.listen.rest.v("1").transcribe_file(payload, options)
|
56 |
print(response.to_json(indent=4))
|
57 |
transcript = response['results']['channels'][0]['alternatives'][0]['transcript']
|
58 |
print(transcript)
|