Redmind commited on
Commit
790f0aa
1 Parent(s): 4d6ac72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
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
- #AUDIO_URL = {
35
- #"url": "https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"
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").transcribe_url(audio_file, options)
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)