nevreal commited on
Commit
ce9b901
β€’
1 Parent(s): 79dbcf9

Update rvc.py

Browse files
Files changed (1) hide show
  1. rvc.py +87 -24
rvc.py CHANGED
@@ -31,6 +31,34 @@ model_library = CachedModels()
31
 
32
 
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  with gr.Blocks(title="πŸ”Š Nex RVC Mobile",theme=gr.themes.Base()) as app:
35
 
36
  gr.Markdown("# Nex RVC MOBILE GUI")
@@ -91,16 +119,66 @@ with gr.Blocks(title="πŸ”Š Nex RVC Mobile",theme=gr.themes.Base()) as app:
91
 
92
  with gr.Row():
93
 
94
- tts_text = gr.Textbox(label="Text to Speech", placeholder="Enter text to convert to speech")
95
-
96
- with gr.Row():
97
-
98
- tts_lang = gr.Radio(choices=["en","es","it","pt"],label="",value="en")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
  with gr.Row():
101
 
102
- tts_button = gr.Button(value="Speak", variant="primary")
103
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  with gr.Row():
105
 
106
  paths_for_files = lambda path:[os.path.abspath(os.path.join(path, f)) for f in os.listdir(path) if os.path.splitext(f)[1].lower() in ('.mp3', '.wav', '.flac', '.ogg')]
@@ -147,23 +225,8 @@ with gr.Blocks(title="πŸ”Š Nex RVC Mobile",theme=gr.themes.Base()) as app:
147
 
148
  outputs=[input_audio0])
149
 
150
- tts_button.click(
151
-
152
- fn=whisperspeak,
153
-
154
- inputs=[tts_text,tts_lang],
155
-
156
- outputs=[input_audio0],
157
-
158
- show_progress=True)
159
-
160
- tts_button.click(
161
-
162
- fn=lambda: {"choices":paths_for_files('audios'),"__type__":"update"},
163
-
164
- inputs=[],
165
-
166
- outputs=[input_audio0])
167
 
168
  with gr.Column():
169
 
 
31
 
32
 
33
 
34
+
35
+
36
+
37
+
38
+ def roformer_separator(roformer_audio, roformer_output_format="wav", roformer_overlap="4", roformer_segment_size="256"):
39
+ files_list = []
40
+ files_list.clear()
41
+ directory = "./audios"
42
+ random_id = str(random.randint(10000, 99999))
43
+ pattern = f"{random_id}"
44
+ os.makedirs("outputs", exist_ok=True)
45
+ write(f'{random_id}.wav', roformer_audio[0], roformer_audio[1])
46
+ full_roformer_model = "model_bs_roformer_ep_317_sdr_12.9755.ckpt"
47
+ prompt = f"audio-separator {random_id}.wav --model_filename {full_roformer_model} --output_dir=./outputs --output_format={roformer_output_format} --normalization=0.9 --mdxc_overlap={roformer_overlap} --mdxc_segment_size={roformer_segment_size}"
48
+ os.system(prompt)
49
+
50
+ for file in os.listdir(directory):
51
+ if re.search(pattern, file):
52
+ files_list.append(os.path.join(directory, file))
53
+
54
+ stem1_file = files_list[0]
55
+ stem2_file = files_list[1]
56
+
57
+ return stem1_file, stem2_file
58
+
59
+
60
+
61
+
62
  with gr.Blocks(title="πŸ”Š Nex RVC Mobile",theme=gr.themes.Base()) as app:
63
 
64
  gr.Markdown("# Nex RVC MOBILE GUI")
 
119
 
120
  with gr.Row():
121
 
122
+ roformer_audio = gr.Audio(
123
+
124
+ label = "Input Audio",
125
+
126
+ type = "numpy",
127
+
128
+ interactive = True
129
+
130
+ )
131
+ with gr.Accordion("Separation by Link", open=False):
132
+ with gr.Row():
133
+ roformer_link = gr.Textbox(
134
+ label = "Link",
135
+
136
+ placeholder = "Paste the link here",
137
+
138
+ interactive = True
139
+ )
140
+ with gr.Row():
141
+ gr.Markdown("You can paste the link to the video/audio from many sites, check the complete list [here](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)")
142
+
143
+ with gr.Row():
144
+ roformer_download_button = gr.Button(
145
+
146
+ "Download!",
147
+
148
+ variant = "primary"
149
+
150
+ )
151
+
152
+ roformer_download_button.click(download_audio, [roformer_link], [roformer_audio])
153
 
154
  with gr.Row():
155
 
156
+ roformer_button = gr.Button("Separate!", variant = "primary")
157
+ with gr.Column():
158
+ roformer_stem1 = gr.Audio(
159
+
160
+ show_download_button = True,
161
+
162
+ interactive = False,
163
+
164
+ label = "Stem 1",
165
+
166
+ type = "filepath"
167
+
168
+ )
169
+
170
+ roformer_stem2 = gr.Audio(
171
+
172
+ show_download_button = True,
173
+
174
+ interactive = False,
175
+
176
+ label = "Stem 2",
177
+
178
+ type = "filepath"
179
+
180
+ )
181
+
182
  with gr.Row():
183
 
184
  paths_for_files = lambda path:[os.path.abspath(os.path.join(path, f)) for f in os.listdir(path) if os.path.splitext(f)[1].lower() in ('.mp3', '.wav', '.flac', '.ogg')]
 
225
 
226
  outputs=[input_audio0])
227
 
228
+ roformer_button.click(roformer_separator, [roformer_audio], [roformer_stem1, roformer_stem2])
229
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
 
231
  with gr.Column():
232