Spaces:
Sleeping
Sleeping
update for mp3
Browse files
app.py
CHANGED
@@ -2,7 +2,14 @@ import gradio as gr
|
|
2 |
import torch
|
3 |
import torchaudio
|
4 |
from df import enhance, init_df
|
|
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
# Initialize DeepFilterNet model
|
7 |
model, df_state, _ = init_df()
|
8 |
|
@@ -16,7 +23,8 @@ def denoise_audio(audio):
|
|
16 |
# Save and return the enhanced audio file
|
17 |
output_file = "enhanced_output.wav"
|
18 |
torchaudio.save(output_file, enhanced_audio, sample_rate)
|
19 |
-
|
|
|
20 |
return output_file
|
21 |
|
22 |
# Gradio interface
|
|
|
2 |
import torch
|
3 |
import torchaudio
|
4 |
from df import enhance, init_df
|
5 |
+
from pydub import AudioSegment
|
6 |
|
7 |
+
def wav_to_mp3(wav_path, mp3_path):
|
8 |
+
# Load the WAV file
|
9 |
+
audio = AudioSegment.from_wav(wav_path)
|
10 |
+
# Export as MP3
|
11 |
+
audio.export(mp3_path, format="mp3")
|
12 |
+
|
13 |
# Initialize DeepFilterNet model
|
14 |
model, df_state, _ = init_df()
|
15 |
|
|
|
23 |
# Save and return the enhanced audio file
|
24 |
output_file = "enhanced_output.wav"
|
25 |
torchaudio.save(output_file, enhanced_audio, sample_rate)
|
26 |
+
wav_to_mp3(output_file,"enhanced.mp3")
|
27 |
+
output_file="enhanced.mp3"
|
28 |
return output_file
|
29 |
|
30 |
# Gradio interface
|