YosefAyele commited on
Commit
e9c0f26
·
1 Parent(s): e78b8e2

fixes filepath

Browse files
Files changed (1) hide show
  1. app.py +3 -14
app.py CHANGED
@@ -35,22 +35,11 @@ def transcribe_audio(audio_file):
35
 
36
  return transcription
37
 
38
- def save_audio_to_file(audio_data, file_path="temp_audio/input_audio.wav"):
39
- """
40
- Converts Gradio audio data (numpy array and sample rate) to a .wav file.
41
- """
42
- audio_array, sample_rate = audio_data
43
- # Normalize and save as .wav
44
- os.makedirs(os.path.dirname(file_path), exist_ok=True)
45
- write(file_path, sample_rate, np.int16(audio_array * 32767)) # Convert float32 to int16
46
- return file_path
47
-
48
  def process_audio(audio_data):
49
  """
50
  Processes recorded/uploaded audio, saves it, and sends it to the transcribe_audio function.
51
- """
52
- temp_audio_path = save_audio_to_file(audio_data)
53
- transcription = transcribe_audio(temp_audio_path)
54
  return transcription
55
 
56
 
@@ -60,7 +49,7 @@ with gr.Blocks() as app:
60
  gr.Markdown("Upload or record an audio file in any format, and get its transcription.")
61
 
62
  with gr.Row():
63
- audio_input = gr.Audio(label="Upload or Record Audio", type="numpy")
64
  transcription_output = gr.Textbox(label="Transcription")
65
 
66
  transcribe_button = gr.Button("Transcribe")
 
35
 
36
  return transcription
37
 
 
 
 
 
 
 
 
 
 
 
38
  def process_audio(audio_data):
39
  """
40
  Processes recorded/uploaded audio, saves it, and sends it to the transcribe_audio function.
41
+ """
42
+ transcription = transcribe_audio(audio_data)
 
43
  return transcription
44
 
45
 
 
49
  gr.Markdown("Upload or record an audio file in any format, and get its transcription.")
50
 
51
  with gr.Row():
52
+ audio_input = gr.Audio(label="Upload or Record Audio", type="filepath")
53
  transcription_output = gr.Textbox(label="Transcription")
54
 
55
  transcribe_button = gr.Button("Transcribe")