tommy24 commited on
Commit
220d524
·
1 Parent(s): 1a3f775

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -220,17 +220,19 @@ def function(Textbox, Textbox2, Textbox3, Dropdown):
220
  def download_audio(url, output_file):
221
  urllib.request.urlretrieve(url, output_file)
222
 
223
- output_file = "audio.mp3"
 
 
 
 
 
224
  download_audio(output, output_file)
225
- # audio_data = base64.b64decode(output)
226
- # return audio_data
227
 
228
- # mp3_path = "output.mp3"
229
- # with open(mp3_path, "wb") as f:
230
- # f.write(audio_data)
231
 
232
- # Return the path to the MP3 file
233
- return output_file
234
  except Exception as e:
235
  print(traceback.format_exc())
236
  return "Please Wait!"
 
220
  def download_audio(url, output_file):
221
  urllib.request.urlretrieve(url, output_file)
222
 
223
+ def convert_wav_to_mp3(wav_file, mp3_file):
224
+ audio = AudioSegment.from_wav(wav_file)
225
+ audio.export(mp3_file, format='mp3')
226
+
227
+ output_file = "audio.wav"
228
+
229
  download_audio(output, output_file)
230
+ convert_wav_to_mp3(output_file, "audio.mp3")
 
231
 
232
+ with open("audio.mp3", "rb") as file:
233
+ audio_data = file.read()
 
234
 
235
+ return audio_data
 
236
  except Exception as e:
237
  print(traceback.format_exc())
238
  return "Please Wait!"