From 5cb86106ceeca06cc0f639cc4c32434b206acce8 Mon Sep 17 00:00:00 2001 From: mrq Date: Sun, 19 Mar 2023 22:03:41 +0000 Subject: [PATCH] option to set results folder location --- src/utils.py | 6 +++++- src/webui.py | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/utils.py b/src/utils.py index 52a294a..714b57c 100755 --- a/src/utils.py +++ b/src/utils.py @@ -252,7 +252,7 @@ def generate(**kwargs): full_start_time = time.time() - outdir = f"./results/{voice}/" + outdir = f"./{args.results_folder}/{voice}/" os.makedirs(outdir, exist_ok=True) audio_cache = {} @@ -2024,6 +2024,7 @@ def setup_args(): 'output-sample-rate': 44100, 'output-volume': 1, + 'results-folder': "./results/", 'tts-backend': TTSES[0], @@ -2070,6 +2071,7 @@ def setup_args(): 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)") parser.add_argument("--output-sample-rate", type=int, default=default_arguments['output-sample-rate'], help="Sample rate to resample the output to (from 24KHz)") parser.add_argument("--output-volume", type=float, default=default_arguments['output-volume'], help="Adjusts volume of output") + parser.add_argument("--results-folder", type=str, default=default_arguments['results-folder'], help="Sets output directory") parser.add_argument("--tts-backend", default=default_arguments['tts-backend'], help="Specifies which TTS backend to use.") @@ -2137,6 +2139,7 @@ def get_default_settings( hypenated=True ): 'output-sample-rate': args.output_sample_rate, 'autocalculate-voice-chunk-duration-size': args.autocalculate_voice_chunk_duration_size, 'output-volume': args.output_volume, + 'results-folder': args.results_folder, 'tts-backend': args.tts_backend, @@ -2183,6 +2186,7 @@ def update_args( **kwargs ): args.output_sample_rate = 44000 args.autocalculate_voice_chunk_duration_size = settings['autocalculate_voice_chunk_duration_size'] args.output_volume = settings['output_volume'] + args.results_folder = settings['results_folder'] args.tts_backend = settings['tts_backend'] diff --git a/src/webui.py b/src/webui.py index 78218e7..0993e4e 100755 --- a/src/webui.py +++ b/src/webui.py @@ -120,7 +120,7 @@ def update_training_configs(): def history_view_results( voice ): results = [] files = [] - outdir = f"./results/{voice}/" + outdir = f"./{args.results_folder}/{voice}/" for i, file in enumerate(sorted(os.listdir(outdir))): if file[-4:] != ".wav": continue @@ -281,11 +281,11 @@ def update_voices(): return ( gr.Dropdown.update(choices=get_voice_list(append_defaults=True)), gr.Dropdown.update(choices=get_voice_list()), - gr.Dropdown.update(choices=get_voice_list("./results/")), + gr.Dropdown.update(choices=get_voice_list(args.results_folder)), ) def history_copy_settings( voice, file ): - return import_generate_settings( f"./results/{voice}/{file}" ) + return import_generate_settings( f"./{args.results_folder}/{voice}/{file}" ) def setup_gradio(): global args @@ -309,7 +309,7 @@ def setup_gradio(): voice_list_with_defaults = get_voice_list(append_defaults=True) voice_list = get_voice_list() - result_voices = get_voice_list("./results/") + result_voices = get_voice_list(args.results_folder) autoregressive_models = get_autoregressive_models() diffusion_models = get_diffusion_models() @@ -571,6 +571,8 @@ def setup_gradio(): EXEC_SETTINGS['autocalculate_voice_chunk_duration_size'] = gr.Number(label="Auto-Calculate Voice Chunk Duration (in seconds)", precision=0, value=args.autocalculate_voice_chunk_duration_size) EXEC_SETTINGS['output_volume'] = gr.Slider(label="Output Volume", minimum=0, maximum=2, value=args.output_volume) EXEC_SETTINGS['device_override'] = gr.Textbox(label="Device Override", value=args.device_override) + + EXEC_SETTINGS['results_folder'] = gr.Textbox(label="Results Folder", value=args.results_folder) with gr.Column(): # EXEC_SETTINGS['tts_backend'] = gr.Dropdown(TTSES, label="TTS Backend", value=args.tts_backend if args.tts_backend else TTSES[0]) @@ -651,7 +653,7 @@ def setup_gradio(): ] ) history_results_list.change( - fn=lambda voice, file: f"./results/{voice}/{file}", + fn=lambda voice, file: f"./{args.results_folder}/{voice}/{file}", inputs=[ history_voices, history_results_list,