fffiloni commited on
Commit
1d51206
β€’
1 Parent(s): d2d12d5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +589 -0
app.py ADDED
@@ -0,0 +1,589 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from share_btn import community_icon_html, loading_icon_html, share_js
3
+ import os
4
+ import shutil
5
+ import re
6
+
7
+ #from huggingface_hub import snapshot_download
8
+ import numpy as np
9
+ from scipy.io import wavfile
10
+ from scipy.io.wavfile import write, read
11
+ from pydub import AudioSegment
12
+
13
+ file_upload_available = os.environ.get("ALLOW_FILE_UPLOAD")
14
+ MAX_NUMBER_SENTENCES = 10
15
+
16
+ import json
17
+ with open("characters.json", "r") as file:
18
+ data = json.load(file)
19
+ characters = [
20
+ {
21
+ "image": item["image"],
22
+ "title": item["title"],
23
+ "speaker": item["speaker"]
24
+ }
25
+ for item in data
26
+ ]
27
+
28
+ from TTS.api import TTS
29
+ tts = TTS("tts_models/multilingual/multi-dataset/bark", gpu=True)
30
+
31
+ def cut_wav(input_path, max_duration):
32
+ # Load the WAV file
33
+ audio = AudioSegment.from_wav(input_path)
34
+
35
+ # Calculate the duration of the audio
36
+ audio_duration = len(audio) / 1000 # Convert milliseconds to seconds
37
+
38
+ # Determine the duration to cut (maximum of max_duration and actual audio duration)
39
+ cut_duration = min(max_duration, audio_duration)
40
+
41
+ # Cut the audio
42
+ cut_audio = audio[:int(cut_duration * 1000)] # Convert seconds to milliseconds
43
+
44
+ # Get the input file name without extension
45
+ file_name = os.path.splitext(os.path.basename(input_path))[0]
46
+
47
+ # Construct the output file path with the original file name and "_cut" suffix
48
+ output_path = f"{file_name}_cut.wav"
49
+
50
+ # Save the cut audio as a new WAV file
51
+ cut_audio.export(output_path, format="wav")
52
+
53
+ return output_path
54
+
55
+ def load_hidden(audio_in):
56
+ return audio_in
57
+
58
+ def load_hidden_mic(audio_in):
59
+ print("USER RECORDED A NEW SAMPLE")
60
+
61
+ library_path = 'bark_voices'
62
+ folder_name = 'audio-0-100'
63
+ second_folder_name = 'audio-0-100_cleaned'
64
+
65
+ folder_path = os.path.join(library_path, folder_name)
66
+ second_folder_path = os.path.join(library_path, second_folder_name)
67
+
68
+ print("We need to clean previous util files, if needed:")
69
+ if os.path.exists(folder_path):
70
+ try:
71
+ shutil.rmtree(folder_path)
72
+ print(f"Successfully deleted the folder previously created from last raw recorded sample: {folder_path}")
73
+ except OSError as e:
74
+ print(f"Error: {folder_path} - {e.strerror}")
75
+ else:
76
+ print(f"OK, the folder for a raw recorded sample does not exist: {folder_path}")
77
+
78
+ if os.path.exists(second_folder_path):
79
+ try:
80
+ shutil.rmtree(second_folder_path)
81
+ print(f"Successfully deleted the folder previously created from last cleaned recorded sample: {second_folder_path}")
82
+ except OSError as e:
83
+ print(f"Error: {second_folder_path} - {e.strerror}")
84
+ else:
85
+ print(f"Ok, the folder for a cleaned recorded sample does not exist: {second_folder_path}")
86
+
87
+ return audio_in
88
+
89
+ def clear_clean_ckeck():
90
+ return False
91
+
92
+ def wipe_npz_file(folder_path):
93
+ print("YO β€’ a user is manipulating audio inputs")
94
+
95
+ def split_process(audio, chosen_out_track):
96
+ gr.Info("Cleaning your audio sample...")
97
+ os.makedirs("out", exist_ok=True)
98
+ write('test.wav', audio[0], audio[1])
99
+ os.system("python3 -m demucs.separate -n mdx_extra_q -j 4 test.wav -o out")
100
+ #return "./out/mdx_extra_q/test/vocals.wav","./out/mdx_extra_q/test/bass.wav","./out/mdx_extra_q/test/drums.wav","./out/mdx_extra_q/test/other.wav"
101
+ if chosen_out_track == "vocals":
102
+ print("Audio sample cleaned")
103
+ return "./out/mdx_extra_q/test/vocals.wav"
104
+ elif chosen_out_track == "bass":
105
+ return "./out/mdx_extra_q/test/bass.wav"
106
+ elif chosen_out_track == "drums":
107
+ return "./out/mdx_extra_q/test/drums.wav"
108
+ elif chosen_out_track == "other":
109
+ return "./out/mdx_extra_q/test/other.wav"
110
+ elif chosen_out_track == "all-in":
111
+ return "test.wav"
112
+
113
+ def update_selection(selected_state: gr.SelectData):
114
+ c_image = characters[selected_state.index]["image"]
115
+ c_title = characters[selected_state.index]["title"]
116
+ c_speaker = characters[selected_state.index]["speaker"]
117
+
118
+ return c_title, selected_state
119
+
120
+
121
+ def infer(prompt, input_wav_file, clean_audio, hidden_numpy_audio):
122
+ print("""
123
+ β€”β€”β€”β€”β€”
124
+ NEW INFERENCE:
125
+ β€”β€”β€”β€”β€”β€”β€”
126
+ """)
127
+ if prompt == "":
128
+ gr.Warning("Do not forget to provide a tts prompt !")
129
+
130
+ if clean_audio is True :
131
+ print("We want to clean audio sample")
132
+ # Extract the file name without the extension
133
+ new_name = os.path.splitext(os.path.basename(input_wav_file))[0]
134
+ print(f"FILE BASENAME is: {new_name}")
135
+ if os.path.exists(os.path.join("bark_voices", f"{new_name}_cleaned")):
136
+ print("This file has already been cleaned")
137
+ check_name = os.path.join("bark_voices", f"{new_name}_cleaned")
138
+ source_path = os.path.join(check_name, f"{new_name}_cleaned.wav")
139
+ else:
140
+ print("This file is new, we need to clean and store it")
141
+ source_path = split_process(hidden_numpy_audio, "vocals")
142
+
143
+ # Rename the file
144
+ new_path = os.path.join(os.path.dirname(source_path), f"{new_name}_cleaned.wav")
145
+ os.rename(source_path, new_path)
146
+ source_path = new_path
147
+ else :
148
+ print("We do NOT want to clean audio sample")
149
+ # Path to your WAV file
150
+ source_path = input_wav_file
151
+
152
+ # Destination directory
153
+ destination_directory = "bark_voices"
154
+
155
+ # Extract the file name without the extension
156
+ file_name = os.path.splitext(os.path.basename(source_path))[0]
157
+
158
+ # Construct the full destination directory path
159
+ destination_path = os.path.join(destination_directory, file_name)
160
+
161
+ # Create the new directory
162
+ os.makedirs(destination_path, exist_ok=True)
163
+
164
+ # Move the WAV file to the new directory
165
+ shutil.move(source_path, os.path.join(destination_path, f"{file_name}.wav"))
166
+
167
+ # β€”β€”β€”β€”β€”
168
+
169
+ # Split the text into sentences based on common punctuation marks
170
+ sentences = re.split(r'(?<=[.!?])\s+', prompt)
171
+
172
+ if len(sentences) > MAX_NUMBER_SENTENCES:
173
+ gr.Info("Your text is too long. To keep this demo enjoyable for everyone, we only kept the first 10 sentences :) Duplicate this space and set MAX_NUMBER_SENTENCES for longer texts ;)")
174
+ # Keep only the first MAX_NUMBER_SENTENCES sentences
175
+ first_nb_sentences = sentences[:MAX_NUMBER_SENTENCES]
176
+
177
+ # Join the selected sentences back into a single string
178
+ limited_prompt = ' '.join(first_nb_sentences)
179
+ prompt = limited_prompt
180
+
181
+ else:
182
+ prompt = prompt
183
+
184
+ gr.Info("Generating audio from prompt")
185
+ tts.tts_to_file(text=prompt,
186
+ file_path="output.wav",
187
+ voice_dir="bark_voices/",
188
+ speaker=f"{file_name}")
189
+
190
+ # List all the files and subdirectories in the given directory
191
+ contents = os.listdir(f"bark_voices/{file_name}")
192
+
193
+ # Print the contents
194
+ for item in contents:
195
+ print(item)
196
+ print("Preparing final waveform video ...")
197
+ tts_video = gr.make_waveform(audio="output.wav")
198
+ print(tts_video)
199
+ print("FINISHED")
200
+ return "output.wav", tts_video, gr.update(value=f"bark_voices/{file_name}/{contents[1]}", visible=True), gr.Group.update(visible=True), destination_path
201
+
202
+ def infer_from_c(prompt, c_name):
203
+ print("""
204
+ β€”β€”β€”β€”β€”
205
+ NEW INFERENCE:
206
+ β€”β€”β€”β€”β€”β€”β€”
207
+ """)
208
+ if prompt == "":
209
+ gr.Warning("Do not forget to provide a tts prompt !")
210
+ print("Warning about prompt sent to user")
211
+
212
+ print(f"USING VOICE LIBRARY: {c_name}")
213
+ # Split the text into sentences based on common punctuation marks
214
+ sentences = re.split(r'(?<=[.!?])\s+', prompt)
215
+
216
+ if len(sentences) > MAX_NUMBER_SENTENCES:
217
+ gr.Info("Your text is too long. To keep this demo enjoyable for everyone, we only kept the first 10 sentences :) Duplicate this space and set MAX_NUMBER_SENTENCES for longer texts ;)")
218
+ # Keep only the first MAX_NUMBER_SENTENCES sentences
219
+ first_nb_sentences = sentences[:MAX_NUMBER_SENTENCES]
220
+
221
+ # Join the selected sentences back into a single string
222
+ limited_prompt = ' '.join(first_nb_sentences)
223
+ prompt = limited_prompt
224
+
225
+ else:
226
+ prompt = prompt
227
+
228
+
229
+ if c_name == "":
230
+ gr.Warning("Voice character is not properly selected. Please ensure that the name of the chosen voice is specified in the Character Name input.")
231
+ print("Warning about Voice Name sent to user")
232
+ else:
233
+ print(f"Generating audio from prompt with {c_name} ;)")
234
+
235
+ tts.tts_to_file(text=prompt,
236
+ file_path="output.wav",
237
+ voice_dir="examples/library/",
238
+ speaker=f"{c_name}")
239
+
240
+ print("Preparing final waveform video ...")
241
+ tts_video = gr.make_waveform(audio="output.wav")
242
+ print(tts_video)
243
+ print("FINISHED")
244
+ return "output.wav", tts_video, gr.update(value=f"examples/library/{c_name}/{c_name}.npz", visible=True), gr.Group.update(visible=True)
245
+
246
+
247
+ css = """
248
+ #col-container {max-width: 780px; margin-left: auto; margin-right: auto;}
249
+ a {text-decoration-line: underline; font-weight: 600;}
250
+ .mic-wrap > button {
251
+ width: 100%;
252
+ height: 60px;
253
+ font-size: 1.4em!important;
254
+ }
255
+ .record-icon.svelte-1thnwz {
256
+ display: flex;
257
+ position: relative;
258
+ margin-right: var(--size-2);
259
+ width: unset;
260
+ height: unset;
261
+ }
262
+ span.record-icon > span.dot.svelte-1thnwz {
263
+ width: 20px!important;
264
+ height: 20px!important;
265
+ }
266
+ .animate-spin {
267
+ animation: spin 1s linear infinite;
268
+ }
269
+ @keyframes spin {
270
+ from {
271
+ transform: rotate(0deg);
272
+ }
273
+ to {
274
+ transform: rotate(360deg);
275
+ }
276
+ }
277
+ #share-btn-container {
278
+ display: flex;
279
+ padding-left: 0.5rem !important;
280
+ padding-right: 0.5rem !important;
281
+ background-color: #000000;
282
+ justify-content: center;
283
+ align-items: center;
284
+ border-radius: 9999px !important;
285
+ max-width: 15rem;
286
+ height: 36px;
287
+ }
288
+ div#share-btn-container > div {
289
+ flex-direction: row;
290
+ background: black;
291
+ align-items: center;
292
+ }
293
+ #share-btn-container:hover {
294
+ background-color: #060606;
295
+ }
296
+ #share-btn {
297
+ all: initial;
298
+ color: #ffffff;
299
+ font-weight: 600;
300
+ cursor:pointer;
301
+ font-family: 'IBM Plex Sans', sans-serif;
302
+ margin-left: 0.5rem !important;
303
+ padding-top: 0.5rem !important;
304
+ padding-bottom: 0.5rem !important;
305
+ right:0;
306
+ }
307
+ #share-btn * {
308
+ all: unset;
309
+ }
310
+ #share-btn-container div:nth-child(-n+2){
311
+ width: auto !important;
312
+ min-height: 0px !important;
313
+ }
314
+ #share-btn-container .wrap {
315
+ display: none !important;
316
+ }
317
+ #share-btn-container.hidden {
318
+ display: none!important;
319
+ }
320
+ img[src*='#center'] {
321
+ display: block;
322
+ margin: auto;
323
+ }
324
+ .footer {
325
+ margin-bottom: 45px;
326
+ margin-top: 10px;
327
+ text-align: center;
328
+ border-bottom: 1px solid #e5e5e5;
329
+ }
330
+ .footer>p {
331
+ font-size: .8rem;
332
+ display: inline-block;
333
+ padding: 0 10px;
334
+ transform: translateY(10px);
335
+ background: white;
336
+ }
337
+ .dark .footer {
338
+ border-color: #303030;
339
+ }
340
+ .dark .footer>p {
341
+ background: #0b0f19;
342
+ }
343
+ .disclaimer {
344
+ text-align: left;
345
+ }
346
+ .disclaimer > p {
347
+ font-size: .8rem;
348
+ }
349
+ """
350
+
351
+ with gr.Blocks(css=css) as demo:
352
+ with gr.Column(elem_id="col-container"):
353
+
354
+ gr.Markdown("""
355
+ <h1 style="text-align: center;">Coqui + Bark Voice Cloning</h1>
356
+ <p style="text-align: center;">
357
+ Mimic any voice character in less than 2 minutes with this <a href="https://tts.readthedocs.io/en/dev/models/bark.html" target="_blank">Coqui TTS + Bark</a> demo ! <br />
358
+ Upload a clean 20 seconds WAV file of the vocal persona you want to mimic, <br />
359
+ type your text-to-speech prompt and hit submit ! <br />
360
+ </p>
361
+ [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-sm.svg#center)](https://huggingface.co/spaces/fffiloni/instant-TTS-Bark-cloning?duplicate=true)
362
+
363
+ """)
364
+ with gr.Row():
365
+ with gr.Column():
366
+ prompt = gr.Textbox(
367
+ label = "Text to speech prompt",
368
+ info = "One or two sentences at a time is better* (max: 10)",
369
+ placeholder = "Hello friend! How are you today?",
370
+ elem_id = "tts-prompt"
371
+ )
372
+
373
+ with gr.Tab("File upload"):
374
+
375
+ with gr.Column():
376
+
377
+ if file_upload_available == "True":
378
+ audio_in = gr.Audio(
379
+ label="WAV voice to clone",
380
+ type="filepath",
381
+ source="upload"
382
+ )
383
+ else:
384
+ audio_in = gr.Audio(
385
+ label="WAV voice to clone",
386
+ type="filepath",
387
+ source="upload",
388
+ interactive = False
389
+ )
390
+ clean_sample = gr.Checkbox(label="Clean sample ?", value=False)
391
+ hidden_audio_numpy = gr.Audio(type="numpy", visible=False)
392
+ submit_btn = gr.Button("Submit")
393
+
394
+ with gr.Tab("Microphone"):
395
+ texts_samples = gr.Textbox(label = "Helpers",
396
+ info = "You can read out loud one of these sentences if you do not know what to record :)",
397
+ value = """"Jazz, a quirky mix of groovy saxophones and wailing trumpets, echoes through the vibrant city streets."
398
+ β€”β€”β€”
399
+ "A majestic orchestra plays enchanting melodies, filling the air with harmony."
400
+ β€”β€”β€”
401
+ "The exquisite aroma of freshly baked bread wafts from a cozy bakery, enticing passersby."
402
+ β€”β€”β€”
403
+ "A thunderous roar shakes the ground as a massive jet takes off into the sky, leaving trails of white behind."
404
+ β€”β€”β€”
405
+ "Laughter erupts from a park where children play, their innocent voices rising like tinkling bells."
406
+ β€”β€”β€”
407
+ "Waves crash on the beach, and seagulls caw as they soar overhead, a symphony of nature's sounds."
408
+ β€”β€”β€”
409
+ "In the distance, a blacksmith hammers red-hot metal, the rhythmic clang punctuating the day."
410
+ β€”β€”β€”
411
+ "As evening falls, a soft hush blankets the world, crickets chirping in a soothing rhythm."
412
+ """,
413
+ interactive = False,
414
+ lines = 5
415
+ )
416
+ micro_in = gr.Audio(
417
+ label="Record voice to clone",
418
+ type="filepath",
419
+ source="microphone",
420
+ interactive = True
421
+ )
422
+ clean_micro = gr.Checkbox(label="Clean sample ?", value=False)
423
+ micro_submit_btn = gr.Button("Submit")
424
+
425
+ audio_in.upload(fn=load_hidden, inputs=[audio_in], outputs=[hidden_audio_numpy], queue=False)
426
+ micro_in.stop_recording(fn=load_hidden_mic, inputs=[micro_in], outputs=[hidden_audio_numpy], queue=False)
427
+
428
+
429
+ with gr.Tab("Voices Characters"):
430
+ selected_state = gr.State()
431
+ gallery_in = gr.Gallery(
432
+ label="Character Gallery",
433
+ value=[(item["image"], item["title"]) for item in characters],
434
+ interactive = True,
435
+ allow_preview=False,
436
+ columns=3,
437
+ elem_id="gallery",
438
+ show_share_button=False
439
+ )
440
+ c_submit_btn = gr.Button("Submit")
441
+
442
+
443
+ with gr.Column():
444
+
445
+ cloned_out = gr.Audio(
446
+ label="Text to speech output",
447
+ visible = False
448
+ )
449
+
450
+ video_out = gr.Video(
451
+ label = "Waveform video",
452
+ elem_id = "voice-video-out"
453
+ )
454
+
455
+ npz_file = gr.File(
456
+ label = ".npz file",
457
+ visible = False
458
+ )
459
+
460
+ folder_path = gr.Textbox(visible=False)
461
+
462
+
463
+
464
+ character_name = gr.Textbox(
465
+ label="Character Name",
466
+ placeholder="Name that voice character",
467
+ elem_id = "character-name"
468
+ )
469
+
470
+ voice_description = gr.Textbox(
471
+ label="description",
472
+ placeholder="How would you describe that voice ? ",
473
+ elem_id = "voice-description"
474
+ )
475
+
476
+ with gr.Group(elem_id="share-btn-container", visible=False) as share_group:
477
+ community_icon = gr.HTML(community_icon_html)
478
+ loading_icon = gr.HTML(loading_icon_html)
479
+ share_button = gr.Button("Share with Community", elem_id="share-btn")
480
+
481
+ share_button.click(None, [], [], _js=share_js, queue=False)
482
+
483
+ gallery_in.select(
484
+ update_selection,
485
+ outputs=[character_name, selected_state],
486
+ queue=False,
487
+ show_progress=False,
488
+ )
489
+
490
+ audio_in.change(fn=wipe_npz_file, inputs=[folder_path], queue=False)
491
+ micro_in.clear(fn=wipe_npz_file, inputs=[folder_path], queue=False)
492
+
493
+ gr.Examples(
494
+ examples = [
495
+ [
496
+ "Once upon a time, in a cozy little shell, lived a friendly crab named Crabby. Crabby loved his cozy home, but he always felt like something was missing.",
497
+ "./examples/en_speaker_6.wav",
498
+ False,
499
+ None
500
+ ],
501
+ [
502
+ "It was a typical afternoon in the bustling city, the sun shining brightly through the windows of the packed courtroom. Three people sat at the bar, their faces etched with worry and anxiety. ",
503
+ "./examples/en_speaker_9.wav",
504
+ False,
505
+ None
506
+ ],
507
+ ],
508
+ fn = infer,
509
+ inputs = [
510
+ prompt,
511
+ audio_in,
512
+ clean_sample,
513
+ hidden_audio_numpy
514
+ ],
515
+ outputs = [
516
+ cloned_out,
517
+ video_out,
518
+ npz_file,
519
+ share_group,
520
+ folder_path
521
+ ],
522
+ cache_examples = False
523
+ )
524
+
525
+ gr.HTML("""
526
+ <div class="footer">
527
+ <p>
528
+ Coqui + Bark Voice Cloning Demo by πŸ€— <a href="https://twitter.com/fffiloni" target="_blank">Sylvain Filoni</a>
529
+ </p>
530
+ </div>
531
+ <div class="disclaimer">
532
+ <h3> * DISCLAIMER </h3>
533
+ <p>
534
+ I hold no responsibility for the utilization or outcomes of audio content produced using the semantic constructs generated by this model. <br />
535
+ Please ensure that any application of this technology remains within legal and ethical boundaries. <br />
536
+ It is important to utilize this technology for ethical and legal purposes, upholding the standards of creativity and innovation.
537
+ </p>
538
+ </div>
539
+ """)
540
+
541
+ submit_btn.click(
542
+ fn = infer,
543
+ inputs = [
544
+ prompt,
545
+ audio_in,
546
+ clean_sample,
547
+ hidden_audio_numpy
548
+ ],
549
+ outputs = [
550
+ cloned_out,
551
+ video_out,
552
+ npz_file,
553
+ share_group,
554
+ folder_path
555
+ ]
556
+ )
557
+
558
+ micro_submit_btn.click(
559
+ fn = infer,
560
+ inputs = [
561
+ prompt,
562
+ micro_in,
563
+ clean_micro,
564
+ hidden_audio_numpy
565
+ ],
566
+ outputs = [
567
+ cloned_out,
568
+ video_out,
569
+ npz_file,
570
+ share_group,
571
+ folder_path
572
+ ]
573
+ )
574
+
575
+ c_submit_btn.click(
576
+ fn = infer_from_c,
577
+ inputs = [
578
+ prompt,
579
+ character_name
580
+ ],
581
+ outputs = [
582
+ cloned_out,
583
+ video_out,
584
+ npz_file,
585
+ share_group
586
+ ]
587
+ )
588
+
589
+ demo.queue(api_open=False, max_size=10).launch()