Steph1949 commited on
Commit
012dff0
1 Parent(s): 23be391

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -22,14 +22,25 @@ def transcribe(audio):
22
  except Exception as e:
23
  return f"Error: {str(e)}"
24
 
 
 
 
 
 
 
 
 
 
 
 
25
  # Create a Gradio interface
26
  iface = gr.Interface(
27
  fn=transcribe,
28
- inputs=gr.Audio(),
29
  outputs="text",
30
  title="Whisper Transcription",
31
  description="Upload an audio file and get the transcription using Whisper model."
32
  )
33
 
34
  if __name__ == "__main__":
35
- iface.launch()
 
22
  except Exception as e:
23
  return f"Error: {str(e)}"
24
 
25
+ def convert_to_wav(audio_file_path):
26
+ try:
27
+ wav_file_path = os.path.splitext(audio_file_path)[0] + '.wav'
28
+ audio = AudioSegment.from_file(audio_file_path)
29
+ audio.export(wav_file_path, format='wav')
30
+ logging.info(f'Converted {audio_file_path} to {wav_file_path}')
31
+ return wav_file_path
32
+ except Exception as e:
33
+ logging.error(f'Error converting file to WAV: {e}')
34
+ raise
35
+
36
  # Create a Gradio interface
37
  iface = gr.Interface(
38
  fn=transcribe,
39
+ inputs=gr.Audio(type="filepath"),
40
  outputs="text",
41
  title="Whisper Transcription",
42
  description="Upload an audio file and get the transcription using Whisper model."
43
  )
44
 
45
  if __name__ == "__main__":
46
+ iface.launch()