Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import gradio as gr
|
|
8 |
import yt_dlp
|
9 |
import subprocess
|
10 |
from pydub import AudioSegment
|
|
|
11 |
from audio_separator.separator import Separator
|
12 |
from lib.infer import infer_audio
|
13 |
import edge_tts
|
@@ -85,6 +86,72 @@ async def text_to_speech_edge(text, language_code):
|
|
85 |
return tmp_path
|
86 |
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
if __name__ == '__main__':
|
89 |
parser = ArgumentParser()
|
90 |
parser.add_argument("--share", action="store_true", dest="share_enabled", default=False)
|
@@ -143,19 +210,6 @@ with gr.Blocks(title="Hex RVC", theme=gr.themes.Base(primary_hue="red", secondar
|
|
143 |
RMS_MIX_RATE = gr.Slider(label="RMS Mix Rate", minimum=0, maximum=1, value=0.25)
|
144 |
PROTECT = gr.Slider(label="Protect Factor", minimum=0, maximum=1, value=0.33)
|
145 |
|
146 |
-
gr.Markdown("### Advanced Settings")
|
147 |
-
with gr.Accordion("Advanced Settings", open=False):
|
148 |
-
SPLIT_INFER = gr.Checkbox(label="Enable Split Inference", value=False)
|
149 |
-
MIN_SILENCE = gr.Number(label="Min Silence (ms)", value=500)
|
150 |
-
SILENCE_THRESHOLD = gr.Number(label="Silence Threshold (dBFS)", value=-50)
|
151 |
-
SEEK_STEP = gr.Slider(label="Seek Step (ms)", minimum=1, maximum=10, value=1)
|
152 |
-
KEEP_SILENCE = gr.Number(label="Keep Silence (ms)", value=200)
|
153 |
-
FORMANT_SHIFT = gr.Checkbox(label="Enable Formant Shift", value=False)
|
154 |
-
QUEFRENCY = gr.Number(label="Quefrency", value=0)
|
155 |
-
TIMBRE = gr.Number(label="Timbre", value=1)
|
156 |
-
F0_AUTOTUNE = gr.Checkbox(label="Enable F0 Autotune", value=False)
|
157 |
-
OUTPUT_FORMAT = gr.Dropdown(choices=["wav", "flac", "mp3"], label="Output Format", value="wav")
|
158 |
-
|
159 |
gr.Markdown("## Generate Audio")
|
160 |
output_audio = gr.Audio(label="Generated Audio Output", type='filepath')
|
161 |
|
@@ -192,6 +246,15 @@ with gr.Blocks(title="Hex RVC", theme=gr.themes.Base(primary_hue="red", secondar
|
|
192 |
outputs=download_output
|
193 |
)
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
with gr.Tab("Audio Separation"):
|
196 |
gr.Markdown("## Audio Separation")
|
197 |
input_audio = gr.Audio(type="filepath", label="Upload Audio for Separation")
|
|
|
8 |
import yt_dlp
|
9 |
import subprocess
|
10 |
from pydub import AudioSegment
|
11 |
+
from pydub.effects import reverb
|
12 |
from audio_separator.separator import Separator
|
13 |
from lib.infer import infer_audio
|
14 |
import edge_tts
|
|
|
86 |
return tmp_path
|
87 |
|
88 |
|
89 |
+
|
90 |
+
|
91 |
+
# Function to add reverb effect using pydub
|
92 |
+
def add_simple_reverb(input_audio):
|
93 |
+
# Load the uploaded audio file
|
94 |
+
sound = AudioSegment.from_file(input_audio)
|
95 |
+
# Apply reverb effect
|
96 |
+
reverbed_sound = reverb(sound)
|
97 |
+
|
98 |
+
# Export the reverbed sound to a new file-like object (in-memory)
|
99 |
+
output_path = "vocals_with_reverb.wav"
|
100 |
+
reverbed_sound.export(output_path, format='wav')
|
101 |
+
|
102 |
+
# Return the output path for Gradio to handle
|
103 |
+
return output_path
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
# Ensure this function is defined before your Gradio Blocks UI
|
108 |
+
def process_audio(MODEL_NAME, SOUND_PATH, F0_CHANGE, F0_METHOD, MIN_PITCH, MAX_PITCH, CREPE_HOP_LENGTH, INDEX_RATE,
|
109 |
+
FILTER_RADIUS, RMS_MIX_RATE, PROTECT, SPLIT_INFER, MIN_SILENCE, SILENCE_THRESHOLD, SEEK_STEP,
|
110 |
+
KEEP_SILENCE, FORMANT_SHIFT, QUEFRENCY, TIMBRE, F0_AUTOTUNE, OUTPUT_FORMAT, upload_audio=None):
|
111 |
+
|
112 |
+
# If no sound path is given, use the uploaded file
|
113 |
+
if not SOUND_PATH and upload_audio is not None:
|
114 |
+
SOUND_PATH = os.path.join("uploaded_audio", upload_audio.name)
|
115 |
+
with open(SOUND_PATH, "wb") as f:
|
116 |
+
f.write(upload_audio.read())
|
117 |
+
|
118 |
+
# Check if a model name is provided
|
119 |
+
if not MODEL_NAME:
|
120 |
+
return "Please provide a model name."
|
121 |
+
|
122 |
+
# Run the inference process
|
123 |
+
os.system("chmod +x stftpitchshift")
|
124 |
+
inferred_audio = infer_audio(
|
125 |
+
MODEL_NAME,
|
126 |
+
SOUND_PATH,
|
127 |
+
F0_CHANGE,
|
128 |
+
F0_METHOD,
|
129 |
+
MIN_PITCH,
|
130 |
+
MAX_PITCH,
|
131 |
+
CREPE_HOP_LENGTH,
|
132 |
+
INDEX_RATE,
|
133 |
+
FILTER_RADIUS,
|
134 |
+
RMS_MIX_RATE,
|
135 |
+
PROTECT,
|
136 |
+
SPLIT_INFER,
|
137 |
+
MIN_SILENCE,
|
138 |
+
SILENCE_THRESHOLD,
|
139 |
+
SEEK_STEP,
|
140 |
+
KEEP_SILENCE,
|
141 |
+
FORMANT_SHIFT,
|
142 |
+
QUEFRENCY,
|
143 |
+
TIMBRE,
|
144 |
+
F0_AUTOTUNE,
|
145 |
+
OUTPUT_FORMAT
|
146 |
+
)
|
147 |
+
|
148 |
+
return inferred_audio
|
149 |
+
|
150 |
+
|
151 |
+
|
152 |
+
|
153 |
+
|
154 |
+
|
155 |
if __name__ == '__main__':
|
156 |
parser = ArgumentParser()
|
157 |
parser.add_argument("--share", action="store_true", dest="share_enabled", default=False)
|
|
|
210 |
RMS_MIX_RATE = gr.Slider(label="RMS Mix Rate", minimum=0, maximum=1, value=0.25)
|
211 |
PROTECT = gr.Slider(label="Protect Factor", minimum=0, maximum=1, value=0.33)
|
212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
gr.Markdown("## Generate Audio")
|
214 |
output_audio = gr.Audio(label="Generated Audio Output", type='filepath')
|
215 |
|
|
|
246 |
outputs=download_output
|
247 |
)
|
248 |
|
249 |
+
with gr.Tab("Audio Effect (demo)"):
|
250 |
+
input_audio = gr.Textbox(label="Path Audio File")
|
251 |
+
output_audio = gr.Audio(type="filepath", label="Processed Audio with Reverb")
|
252 |
+
|
253 |
+
reverb_btn = gr.Button("Add Reverb")
|
254 |
+
|
255 |
+
reverb_btn.click(add_simple_reverb, inputs=input_audio, outputs=output_audio)
|
256 |
+
|
257 |
+
|
258 |
with gr.Tab("Audio Separation"):
|
259 |
gr.Markdown("## Audio Separation")
|
260 |
input_audio = gr.Audio(type="filepath", label="Upload Audio for Separation")
|