Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
224 |
download_audio(output, output_file)
|
225 |
-
|
226 |
-
# return audio_data
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
# f.write(audio_data)
|
231 |
|
232 |
-
|
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!"
|