Shreyas094 commited on
Commit
cead1c3
·
verified ·
1 Parent(s): 079dfd1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -17,7 +17,7 @@ from huggingface_hub import InferenceClient
17
  import inspect
18
  import logging
19
  import shutil
20
-
21
 
22
  # Set up basic configuration for logging
23
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@@ -626,11 +626,15 @@ def transcribe(audio_file):
626
  audio_file = io.BytesIO(audio_data)
627
  audio_file.name = "audio.wav" # The name is important for the API to recognize the file type
628
 
629
- # Use the automatic_speech_recognition method
630
- response = whisper_api.automatic_speech_recognition(audio=audio_file)
631
-
632
- # The response should be a dictionary with a 'text' key
633
- return response["text"] if isinstance(response, dict) and "text" in response else str(response)
 
 
 
 
634
 
635
  def vote(data: gr.LikeData):
636
  if data.liked:
 
17
  import inspect
18
  import logging
19
  import shutil
20
+ import io
21
 
22
  # Set up basic configuration for logging
23
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
 
626
  audio_file = io.BytesIO(audio_data)
627
  audio_file.name = "audio.wav" # The name is important for the API to recognize the file type
628
 
629
+ try:
630
+ # Use the automatic_speech_recognition method
631
+ response = whisper_api.automatic_speech_recognition(audio=audio_file)
632
+
633
+ # The response should be a dictionary with a 'text' key
634
+ return response["text"] if isinstance(response, dict) and "text" in response else str(response)
635
+ except Exception as e:
636
+ print(f"Error in transcription: {str(e)}")
637
+ return f"Error in transcription: {str(e)}"
638
 
639
  def vote(data: gr.LikeData):
640
  if data.liked: