frogcho123 commited on
Commit
2920572
1 Parent(s): a66dfeb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -8,8 +8,9 @@ model = whisper.load_model("base")
8
  # Function to process the uploaded audio file and perform transcription
9
  def process_audio(upload):
10
  # Save the uploaded audio file
11
- file_path = "uploaded_audio.mp3"
12
- upload.save(file_path)
 
13
 
14
  # Load the audio file and perform preprocessing
15
  audio = whisper.load_audio(file_path)
@@ -25,10 +26,13 @@ def process_audio(upload):
25
  result = whisper.decode(model, mel, options)
26
  transcription = result.text
27
 
 
 
 
28
  return transcription
29
 
30
- # Create an audio input component for uploading the audio file
31
- audio_input = gr.inputs.Audio(label="Upload Audio", type="file")
32
 
33
  # Create a text output component for displaying the transcription
34
  text_output = gr.outputs.Textbox(label="Transcription")
 
8
  # Function to process the uploaded audio file and perform transcription
9
  def process_audio(upload):
10
  # Save the uploaded audio file
11
+ file_path = "uploaded_audio.wav"
12
+ with open(file_path, "wb") as f:
13
+ f.write(upload.read())
14
 
15
  # Load the audio file and perform preprocessing
16
  audio = whisper.load_audio(file_path)
 
26
  result = whisper.decode(model, mel, options)
27
  transcription = result.text
28
 
29
+ # Delete the temporary audio file
30
+ os.remove(file_path)
31
+
32
  return transcription
33
 
34
+ # Create a file input component for uploading the audio file
35
+ audio_input = gr.inputs.File(label="Upload Audio")
36
 
37
  # Create a text output component for displaying the transcription
38
  text_output = gr.outputs.Textbox(label="Transcription")