Hev832 commited on
Commit
903ebdd
·
verified ·
1 Parent(s): 553359a

Rename =0.2.0 to app.py

Browse files
Files changed (2) hide show
  1. =0.2.0 +0 -0
  2. app.py +114 -0
=0.2.0 DELETED
File without changes
app.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from lib.infer import infer_audio
4
+ from pydub import AudioSegment
5
+ import shutil
6
+
7
+ # Main function to process audio
8
+ def process_audio(MODEL_NAME, SOUND_PATH, F0_CHANGE, F0_METHOD, MIN_PITCH, MAX_PITCH, CREPE_HOP_LENGTH, INDEX_RATE,
9
+ FILTER_RADIUS, RMS_MIX_RATE, PROTECT, SPLIT_INFER, MIN_SILENCE, SILENCE_THRESHOLD, SEEK_STEP,
10
+ KEEP_SILENCE, FORMANT_SHIFT, QUEFRENCY, TIMBRE, F0_AUTOTUNE, OUTPUT_FORMAT, upload_audio=None):
11
+
12
+ # If no sound path is given, use the uploaded file
13
+ if not SOUND_PATH and upload_audio is not None:
14
+ SOUND_PATH = os.path.join("uploaded_audio", upload_audio.name)
15
+ with open(SOUND_PATH, "wb") as f:
16
+ f.write(upload_audio.read())
17
+
18
+ # Check if a model name is provided
19
+ if not MODEL_NAME:
20
+ return "Please provide a model name."
21
+
22
+ # Run the inference
23
+ os.system("chmod +x stftpitchshift")
24
+ inferred_audio = infer_audio(
25
+ MODEL_NAME,
26
+ SOUND_PATH,
27
+ F0_CHANGE,
28
+ F0_METHOD,
29
+ MIN_PITCH,
30
+ MAX_PITCH,
31
+ CREPE_HOP_LENGTH,
32
+ INDEX_RATE,
33
+ FILTER_RADIUS,
34
+ RMS_MIX_RATE,
35
+ PROTECT,
36
+ SPLIT_INFER,
37
+ MIN_SILENCE,
38
+ SILENCE_THRESHOLD,
39
+ SEEK_STEP,
40
+ KEEP_SILENCE,
41
+ FORMANT_SHIFT,
42
+ QUEFRENCY,
43
+ TIMBRE,
44
+ F0_AUTOTUNE,
45
+ OUTPUT_FORMAT
46
+ )
47
+
48
+ # Output the inferred audio file
49
+ return inferred_audio
50
+
51
+
52
+ # Gradio Blocks Interface
53
+ with gr.Blocks(tite="Hex RVC") as app:
54
+ gr.Markdown("## Hex RVC")
55
+
56
+ # Model Input
57
+ with gr.Row():
58
+ MODEL_NAME = gr.Textbox(label="Model Name", placeholder="Enter model name")
59
+
60
+ # Audio Upload/Input
61
+ with gr.Row():
62
+ SOUND_PATH = gr.Textbox(label="Audio Path (Optional)", placeholder="Leave blank to upload audio")
63
+ upload_audio = gr.File(label="Upload Audio", type='filepath', file_types=["audio"])
64
+
65
+ # Main Settings
66
+ with gr.Row():
67
+ F0_CHANGE = gr.Number(label="Pitch Change (semitones)", value=0)
68
+ F0_METHOD = gr.Dropdown(choices=["crepe", "harvest", "mangio-crepe", "rmvpe", "rmvpe+", "fcpe", "fcpe_legacy",
69
+ "hybrid[mangio-crepe+rmvpe]", "hybrid[mangio-crepe+fcpe]",
70
+ "hybrid[rmvpe+fcpe]", "hybrid[mangio-crepe+rmvpe+fcpe]"],
71
+ label="F0 Method", value="fcpe")
72
+
73
+ # Other Settings
74
+ with gr.Row():
75
+ MIN_PITCH = gr.Textbox(label="Min Pitch", value="50")
76
+ MAX_PITCH = gr.Textbox(label="Max Pitch", value="1100")
77
+ CREPE_HOP_LENGTH = gr.Number(label="Crepe Hop Length", value=120)
78
+ INDEX_RATE = gr.Slider(label="Index Rate", minimum=0, maximum=1, value=0.75)
79
+ FILTER_RADIUS = gr.Number(label="Filter Radius", value=3)
80
+ RMS_MIX_RATE = gr.Slider(label="RMS Mix Rate", minimum=0, maximum=1, value=0.25)
81
+ PROTECT = gr.Slider(label="Protect", minimum=0, maximum=1, value=0.33)
82
+
83
+ # Advanced Settings
84
+ with gr.Accordion("Advanced Settings", open=False):
85
+ SPLIT_INFER = gr.Checkbox(label="Enable Split Inference", value=False)
86
+ MIN_SILENCE = gr.Number(label="Min Silence (ms)", value=500)
87
+ SILENCE_THRESHOLD = gr.Number(label="Silence Threshold (dBFS)", value=-50)
88
+ SEEK_STEP = gr.Slider(label="Seek Step (ms)", minimum=1, maximum=10, value=1)
89
+ KEEP_SILENCE = gr.Number(label="Keep Silence (ms)", value=200)
90
+ FORMANT_SHIFT = gr.Checkbox(label="Enable Formant Shift", value=False)
91
+ QUEFRENCY = gr.Number(label="Quefrency", value=0)
92
+ TIMBRE = gr.Number(label="Timbre", value=1)
93
+ F0_AUTOTUNE = gr.Checkbox(label="Enable F0 Autotune", value=False)
94
+
95
+ # Output Settings
96
+ OUTPUT_FORMAT = gr.Dropdown(choices=["wav", "flac", "mp3"], label="Output Format", value="wav")
97
+
98
+ # Run Button
99
+ run_button = gr.Button("Run Inference")
100
+
101
+ # Audio Output
102
+ output_audio = gr.Audio(label="Generated Audio", type='filepath')
103
+
104
+ # Run the process_audio function on button click
105
+ run_button.click(
106
+ process_audio,
107
+ inputs=[MODEL_NAME, SOUND_PATH, F0_CHANGE, F0_METHOD, MIN_PITCH, MAX_PITCH, CREPE_HOP_LENGTH, INDEX_RATE,
108
+ FILTER_RADIUS, RMS_MIX_RATE, PROTECT, SPLIT_INFER, MIN_SILENCE, SILENCE_THRESHOLD, SEEK_STEP,
109
+ KEEP_SILENCE, FORMANT_SHIFT, QUEFRENCY, TIMBRE, F0_AUTOTUNE, OUTPUT_FORMAT, upload_audio],
110
+ outputs=output_audio
111
+ )
112
+
113
+ # Launch the Gradio app
114
+ app.launch()