arshadrana commited on
Commit
97ce819
·
verified ·
1 Parent(s): c65b28c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -1,19 +1,15 @@
1
  import gradio as gr
2
  import speech_recognition as sr
3
 
4
- def transcribe_audio(audio_file):
5
  recognizer = sr.Recognizer()
6
 
7
- # Check if audio_file is a tuple and extract the file path
8
- if isinstance(audio_file, tuple):
9
- audio_file = audio_file[0]
10
-
11
- # Ensure the audio_file is a file path
12
- if not isinstance(audio_file, str):
13
- raise ValueError("Expected audio_file to be a file path, got {}".format(type(audio_file)))
14
 
15
  # Load the audio file
16
- with sr.AudioFile(audio_file) as source:
17
  audio_data = recognizer.record(source)
18
 
19
  try:
 
1
  import gradio as gr
2
  import speech_recognition as sr
3
 
4
+ def transcribe_audio(audio_file_path):
5
  recognizer = sr.Recognizer()
6
 
7
+ # Ensure the audio_file_path is a file path
8
+ if not isinstance(audio_file_path, str):
9
+ raise ValueError("Expected audio_file_path to be a file path, got {}".format(type(audio_file_path)))
 
 
 
 
10
 
11
  # Load the audio file
12
+ with sr.AudioFile(audio_file_path) as source:
13
  audio_data = recognizer.record(source)
14
 
15
  try: