Spaces:
Build error
Build error
auto-suggested voice chunk size is based on the total duration of the voice files divided by 10 seconds, added setting to adjust the auto-suggested division factor (a really oddly worded one), because I'm sure people will OOM blindly generating without adjusting this slider
Browse files- src/utils.py +23 -3
- src/webui.py +14 -14
src/utils.py
CHANGED
|
@@ -454,6 +454,22 @@ def hash_file(path, algo="md5", buffer_size=0):
|
|
| 454 |
|
| 455 |
return "{0}".format(hash.hexdigest())
|
| 456 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 457 |
def compute_latents(voice, voice_latents_chunks, progress=gr.Progress(track_tqdm=True)):
|
| 458 |
global tts
|
| 459 |
global args
|
|
@@ -1244,6 +1260,7 @@ def setup_args():
|
|
| 1244 |
'prune-nonfinal-outputs': True,
|
| 1245 |
'use-bigvgan-vocoder': True,
|
| 1246 |
'concurrency-count': 2,
|
|
|
|
| 1247 |
'output-sample-rate': 44100,
|
| 1248 |
'output-volume': 1,
|
| 1249 |
|
|
@@ -1282,6 +1299,7 @@ def setup_args():
|
|
| 1282 |
parser.add_argument("--device-override", default=default_arguments['device-override'], help="A device string to override pass through Torch")
|
| 1283 |
parser.add_argument("--sample-batch-size", default=default_arguments['sample-batch-size'], type=int, help="Sets how many batches to use during the autoregressive samples pass")
|
| 1284 |
parser.add_argument("--concurrency-count", type=int, default=default_arguments['concurrency-count'], help="How many Gradio events to process at once")
|
|
|
|
| 1285 |
parser.add_argument("--output-sample-rate", type=int, default=default_arguments['output-sample-rate'], help="Sample rate to resample the output to (from 24KHz)")
|
| 1286 |
parser.add_argument("--output-volume", type=float, default=default_arguments['output-volume'], help="Adjusts volume of output")
|
| 1287 |
|
|
@@ -1321,7 +1339,7 @@ def setup_args():
|
|
| 1321 |
|
| 1322 |
return args
|
| 1323 |
|
| 1324 |
-
def update_args( listen, share, check_for_updates, models_from_local_only, low_vram, embed_output_metadata, latents_lean_and_mean, voice_fixer, voice_fixer_use_cuda, force_cpu_for_conditioning_latents, defer_tts_load, prune_nonfinal_outputs, use_bigvgan_vocoder, device_override, sample_batch_size, concurrency_count,
|
| 1325 |
global args
|
| 1326 |
|
| 1327 |
args.listen = listen
|
|
@@ -1340,7 +1358,8 @@ def update_args( listen, share, check_for_updates, models_from_local_only, low_v
|
|
| 1340 |
args.voice_fixer = voice_fixer
|
| 1341 |
args.voice_fixer_use_cuda = voice_fixer_use_cuda
|
| 1342 |
args.concurrency_count = concurrency_count
|
| 1343 |
-
args.output_sample_rate =
|
|
|
|
| 1344 |
args.output_volume = output_volume
|
| 1345 |
|
| 1346 |
args.autoregressive_model = autoregressive_model
|
|
@@ -1372,6 +1391,7 @@ def save_args_settings():
|
|
| 1372 |
'voice-fixer-use-cuda': args.voice_fixer_use_cuda,
|
| 1373 |
'concurrency-count': args.concurrency_count,
|
| 1374 |
'output-sample-rate': args.output_sample_rate,
|
|
|
|
| 1375 |
'output-volume': args.output_volume,
|
| 1376 |
|
| 1377 |
'autoregressive-model': args.autoregressive_model,
|
|
@@ -1481,7 +1501,7 @@ def load_tts( restart=False, model=None ):
|
|
| 1481 |
tts = TextToSpeech(minor_optimizations=not args.low_vram, autoregressive_model_path=args.autoregressive_model)
|
| 1482 |
except Exception as e:
|
| 1483 |
tts = TextToSpeech(minor_optimizations=not args.low_vram)
|
| 1484 |
-
|
| 1485 |
|
| 1486 |
if not hasattr(tts, 'autoregressive_model_hash'):
|
| 1487 |
tts.autoregressive_model_hash = hash_file(tts.autoregressive_model_path)
|
|
|
|
| 454 |
|
| 455 |
return "{0}".format(hash.hexdigest())
|
| 456 |
|
| 457 |
+
def update_baseline_for_latents_chunks( voice ):
|
| 458 |
+
path = f'{get_voice_dir()}/{voice}/'
|
| 459 |
+
if not os.path.isdir(path):
|
| 460 |
+
return 1
|
| 461 |
+
|
| 462 |
+
files = os.listdir(path)
|
| 463 |
+
total_duration = 0
|
| 464 |
+
for file in files:
|
| 465 |
+
if file[-4:] != ".wav":
|
| 466 |
+
continue
|
| 467 |
+
metadata = torchaudio.info(f'{path}/{file}')
|
| 468 |
+
duration = metadata.num_channels * metadata.num_frames / metadata.sample_rate
|
| 469 |
+
total_duration += duration
|
| 470 |
+
|
| 471 |
+
return int(total_duration / args.autocalculate_voice_chunk_duration_size) if total_duration > 0 else 1
|
| 472 |
+
|
| 473 |
def compute_latents(voice, voice_latents_chunks, progress=gr.Progress(track_tqdm=True)):
|
| 474 |
global tts
|
| 475 |
global args
|
|
|
|
| 1260 |
'prune-nonfinal-outputs': True,
|
| 1261 |
'use-bigvgan-vocoder': True,
|
| 1262 |
'concurrency-count': 2,
|
| 1263 |
+
'autocalculate-voice-chunk-duration-size': 10,
|
| 1264 |
'output-sample-rate': 44100,
|
| 1265 |
'output-volume': 1,
|
| 1266 |
|
|
|
|
| 1299 |
parser.add_argument("--device-override", default=default_arguments['device-override'], help="A device string to override pass through Torch")
|
| 1300 |
parser.add_argument("--sample-batch-size", default=default_arguments['sample-batch-size'], type=int, help="Sets how many batches to use during the autoregressive samples pass")
|
| 1301 |
parser.add_argument("--concurrency-count", type=int, default=default_arguments['concurrency-count'], help="How many Gradio events to process at once")
|
| 1302 |
+
parser.add_argument("--autocalculate-voice-chunk-duration-size", type=float, default=default_arguments['autocalculate-voice-chunk-duration-size'], help="Number of seconds to suggest voice chunk size for (for example, 100 seconds of audio at 10 seconds per chunk will suggest 10 chunks)")
|
| 1303 |
parser.add_argument("--output-sample-rate", type=int, default=default_arguments['output-sample-rate'], help="Sample rate to resample the output to (from 24KHz)")
|
| 1304 |
parser.add_argument("--output-volume", type=float, default=default_arguments['output-volume'], help="Adjusts volume of output")
|
| 1305 |
|
|
|
|
| 1339 |
|
| 1340 |
return args
|
| 1341 |
|
| 1342 |
+
def update_args( listen, share, check_for_updates, models_from_local_only, low_vram, embed_output_metadata, latents_lean_and_mean, voice_fixer, voice_fixer_use_cuda, force_cpu_for_conditioning_latents, defer_tts_load, prune_nonfinal_outputs, use_bigvgan_vocoder, device_override, sample_batch_size, concurrency_count, autocalculate_voice_chunk_duration_size, output_volume, autoregressive_model, whisper_model, whisper_cpp, training_default_halfp, training_default_bnb ):
|
| 1343 |
global args
|
| 1344 |
|
| 1345 |
args.listen = listen
|
|
|
|
| 1358 |
args.voice_fixer = voice_fixer
|
| 1359 |
args.voice_fixer_use_cuda = voice_fixer_use_cuda
|
| 1360 |
args.concurrency_count = concurrency_count
|
| 1361 |
+
args.output_sample_rate = 44000
|
| 1362 |
+
args.autocalculate_voice_chunk_duration_size = autocalculate_voice_chunk_duration_size
|
| 1363 |
args.output_volume = output_volume
|
| 1364 |
|
| 1365 |
args.autoregressive_model = autoregressive_model
|
|
|
|
| 1391 |
'voice-fixer-use-cuda': args.voice_fixer_use_cuda,
|
| 1392 |
'concurrency-count': args.concurrency_count,
|
| 1393 |
'output-sample-rate': args.output_sample_rate,
|
| 1394 |
+
'autocalculate-voice-chunk-duration-size': args.autocalculate_voice_chunk_duration_size,
|
| 1395 |
'output-volume': args.output_volume,
|
| 1396 |
|
| 1397 |
'autoregressive-model': args.autoregressive_model,
|
|
|
|
| 1501 |
tts = TextToSpeech(minor_optimizations=not args.low_vram, autoregressive_model_path=args.autoregressive_model)
|
| 1502 |
except Exception as e:
|
| 1503 |
tts = TextToSpeech(minor_optimizations=not args.low_vram)
|
| 1504 |
+
load_autoregressive_model(args.autoregressive_model)
|
| 1505 |
|
| 1506 |
if not hasattr(tts, 'autoregressive_model_hash'):
|
| 1507 |
tts.autoregressive_model_hash = hash_file(tts.autoregressive_model_path)
|
src/webui.py
CHANGED
|
@@ -385,19 +385,6 @@ def setup_gradio():
|
|
| 385 |
refresh_voices = gr.Button(value="Refresh Voice List")
|
| 386 |
recompute_voice_latents = gr.Button(value="(Re)Compute Voice Latents")
|
| 387 |
|
| 388 |
-
def update_baseline_for_latents_chunks( voice ):
|
| 389 |
-
path = f'{get_voice_dir()}/{voice}/'
|
| 390 |
-
if not os.path.isdir(path):
|
| 391 |
-
return 1
|
| 392 |
-
|
| 393 |
-
files = os.listdir(path)
|
| 394 |
-
count = 0
|
| 395 |
-
for file in files:
|
| 396 |
-
if file[-4:] == ".wav":
|
| 397 |
-
count += 1
|
| 398 |
-
|
| 399 |
-
return count if count > 0 else 1
|
| 400 |
-
|
| 401 |
voice.change(
|
| 402 |
fn=update_baseline_for_latents_chunks,
|
| 403 |
inputs=voice,
|
|
@@ -575,7 +562,7 @@ def setup_gradio():
|
|
| 575 |
exec_inputs = exec_inputs + [
|
| 576 |
gr.Number(label="Sample Batch Size", precision=0, value=args.sample_batch_size),
|
| 577 |
gr.Number(label="Gradio Concurrency Count", precision=0, value=args.concurrency_count),
|
| 578 |
-
gr.Number(label="
|
| 579 |
gr.Slider(label="Output Volume", minimum=0, maximum=2, value=args.output_volume),
|
| 580 |
]
|
| 581 |
|
|
@@ -594,6 +581,7 @@ def setup_gradio():
|
|
| 594 |
inputs=autoregressive_model_dropdown,
|
| 595 |
outputs=None
|
| 596 |
)
|
|
|
|
| 597 |
|
| 598 |
def update_model_list_proxy( val ):
|
| 599 |
autoregressive_models = get_autoregressive_models()
|
|
@@ -814,6 +802,18 @@ def setup_gradio():
|
|
| 814 |
outputs=save_yaml_output #console_output
|
| 815 |
)
|
| 816 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 817 |
if os.path.isfile('./config/generate.json'):
|
| 818 |
ui.load(import_generate_settings, inputs=None, outputs=input_settings)
|
| 819 |
|
|
|
|
| 385 |
refresh_voices = gr.Button(value="Refresh Voice List")
|
| 386 |
recompute_voice_latents = gr.Button(value="(Re)Compute Voice Latents")
|
| 387 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 388 |
voice.change(
|
| 389 |
fn=update_baseline_for_latents_chunks,
|
| 390 |
inputs=voice,
|
|
|
|
| 562 |
exec_inputs = exec_inputs + [
|
| 563 |
gr.Number(label="Sample Batch Size", precision=0, value=args.sample_batch_size),
|
| 564 |
gr.Number(label="Gradio Concurrency Count", precision=0, value=args.concurrency_count),
|
| 565 |
+
gr.Number(label="Auto-Calculate Voice Chunk Duration (in seconds)", precision=0, value=args.autocalculate_voice_chunk_duration_size),
|
| 566 |
gr.Slider(label="Output Volume", minimum=0, maximum=2, value=args.output_volume),
|
| 567 |
]
|
| 568 |
|
|
|
|
| 581 |
inputs=autoregressive_model_dropdown,
|
| 582 |
outputs=None
|
| 583 |
)
|
| 584 |
+
# kill_button = gr.Button(value="Close UI")
|
| 585 |
|
| 586 |
def update_model_list_proxy( val ):
|
| 587 |
autoregressive_models = get_autoregressive_models()
|
|
|
|
| 802 |
outputs=save_yaml_output #console_output
|
| 803 |
)
|
| 804 |
|
| 805 |
+
"""
|
| 806 |
+
def kill_process():
|
| 807 |
+
ui.close()
|
| 808 |
+
exit()
|
| 809 |
+
|
| 810 |
+
kill_button.click(
|
| 811 |
+
kill_process,
|
| 812 |
+
inputs=None,
|
| 813 |
+
outputs=None
|
| 814 |
+
)
|
| 815 |
+
"""
|
| 816 |
+
|
| 817 |
if os.path.isfile('./config/generate.json'):
|
| 818 |
ui.load(import_generate_settings, inputs=None, outputs=input_settings)
|
| 819 |
|