Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,7 @@ import shutil
|
|
21 |
import urllib.request
|
22 |
import gdown
|
23 |
import subprocess
|
|
|
24 |
from argparse import ArgumentParser
|
25 |
main_dir = Path().resolve()
|
26 |
print(main_dir)
|
@@ -30,6 +31,37 @@ models_dir = "models"
|
|
30 |
audio_separat_dir = main_dir / "audio_input"
|
31 |
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
def download_audio(url):
|
35 |
ydl_opts = {
|
@@ -215,9 +247,22 @@ with gr.Blocks(title="Hex RVC", theme=gr.themes.Default(primary_hue="red", secon
|
|
215 |
with gr.Tab("Inference"):
|
216 |
with gr.Row():
|
217 |
MODEL_NAME = gr.Textbox(label="Model Name", placeholder="Enter model name")
|
218 |
-
|
219 |
upload_audio = gr.Audio(label="Upload Audio", type='filepath')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
|
|
|
221 |
with gr.Row():
|
222 |
F0_CHANGE = gr.Number(label="Pitch Change (semitones)", value=0)
|
223 |
F0_METHOD = gr.Dropdown(choices=["crepe", "harvest", "mangio-crepe", "rmvpe", "rmvpe+", "fcpe", "hybrid[rmvpe+fcpe]"],
|
|
|
21 |
import urllib.request
|
22 |
import gdown
|
23 |
import subprocess
|
24 |
+
import time
|
25 |
from argparse import ArgumentParser
|
26 |
main_dir = Path().resolve()
|
27 |
print(main_dir)
|
|
|
31 |
audio_separat_dir = main_dir / "audio_input"
|
32 |
|
33 |
|
34 |
+
# Directory to monitor for audio files
|
35 |
+
AUDIO_DIR = main_dir / 'audio_input'
|
36 |
+
|
37 |
+
# Function to get the list of audio files in the specified directory
|
38 |
+
def get_audio_files():
|
39 |
+
if not os.path.exists(AUDIO_DIR):
|
40 |
+
os.makedirs(AUDIO_DIR)
|
41 |
+
# List all supported audio file formats
|
42 |
+
return [f for f in os.listdir(AUDIO_DIR) if f.lower().endswith(('.mp3', '.wav', '.flac', '.ogg', '.aac'))]
|
43 |
+
|
44 |
+
# Function to return the full path of audio files for playback
|
45 |
+
def load_audio_files():
|
46 |
+
audio_files = get_audio_files()
|
47 |
+
return [os.path.join(AUDIO_DIR, f) for f in audio_files]
|
48 |
+
|
49 |
+
# Refresh function to update the list of files
|
50 |
+
def refresh_audio_list():
|
51 |
+
audio_files = load_audio_files()
|
52 |
+
return gr.update(choices=audio_files)
|
53 |
+
|
54 |
+
# Function to play selected audio file
|
55 |
+
def play_audio(file_path):
|
56 |
+
return file_path
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
|
66 |
def download_audio(url):
|
67 |
ydl_opts = {
|
|
|
247 |
with gr.Tab("Inference"):
|
248 |
with gr.Row():
|
249 |
MODEL_NAME = gr.Textbox(label="Model Name", placeholder="Enter model name")
|
250 |
+
# SOUND_PATH = gr.Textbox(label="Audio Path (Optional)", placeholder="Leave blank to upload audio")
|
251 |
upload_audio = gr.Audio(label="Upload Audio", type='filepath')
|
252 |
+
|
253 |
+
SOUND_PATH = gr.Dropdown(
|
254 |
+
choices=load_audio_files(),
|
255 |
+
label="Select an audio file",
|
256 |
+
interactive=True,
|
257 |
+
value=None,
|
258 |
+
)
|
259 |
+
|
260 |
+
refresh_btn = gr.Button("Refresh Audio List")
|
261 |
+
|
262 |
+
# Set up button click to refresh audio list
|
263 |
+
refresh_btn.click(refresh_audio_list, outputs=audio_dropdown)
|
264 |
|
265 |
+
|
266 |
with gr.Row():
|
267 |
F0_CHANGE = gr.Number(label="Pitch Change (semitones)", value=0)
|
268 |
F0_METHOD = gr.Dropdown(choices=["crepe", "harvest", "mangio-crepe", "rmvpe", "rmvpe+", "fcpe", "hybrid[rmvpe+fcpe]"],
|