diff --git a/lib/gradio.py b/lib/gradio.py index 8c246bc0..4cf8bb40 100644 --- a/lib/gradio.py +++ b/lib/gradio.py @@ -1163,8 +1163,9 @@ def build_interface(args:dict)->gr.Blocks: if session['tts_engine'] in [TTS_ENGINES['VITS'], TTS_ENGINES['FAIRSEQ'], TTS_ENGINES['TACOTRON2'], TTS_ENGINES['YOURTTS']]: voice_options = [('Default', None)] + sorted(voice_options, key=lambda x: x[0].lower()) else: - voice_options = sorted(voice_options, key=lambda x: x[0].lower()) - if session['voice'] is not None and session['voice'] not in voice_options.values(): + voice_options = sorted(voice_options, key=lambda x: x[0].lower()) + session['voice'] = models[session['fine_tuned']]['voice'] if session['voice'] is None and voice_options[0][1] is not None + if session['voice'] is not None and session['voice'] not in voice_options: new_voice_path = session['voice'].replace('/eng/', f"/{session['language']}/") session['voice'] = new_voice_path if os.path.exists(new_voice_path) else models[session['fine_tuned']]['voice'] return gr.update(choices=voice_options, value=session['voice']) @@ -1300,10 +1301,6 @@ def build_interface(args:dict)->gr.Blocks: models = load_engine_presets(engine) session['tts_engine'] = engine session['fine_tuned'] = default_fine_tuned - session['voice'] = models[session['fine_tuned']]['voice'] - if engine in [TTS_ENGINES['XTTSv2']]: - if session['custom_model'] is not None: - session['voice'] = os.path.join(session['custom_model'], f"{os.path.basename(session['custom_model'])}.wav") bark_visible = False if session['tts_engine'] == TTS_ENGINES['XTTSv2']: visible_custom_model = True if session['fine_tuned'] == 'internal' else False @@ -1337,14 +1334,12 @@ def build_interface(args:dict)->gr.Blocks: if selected: session = context.get_session(id) if session: - models = load_engine_presets(session['tts_engine']) session['fine_tuned'] = selected visible_custom_model = False if selected == 'internal': visible_custom_model = visible_gr_group_custom_model else: visible_custom_model = False - session['voice'] = models[selected]['voice'] return gr.update(visible=visible_custom_model), update_gr_voice_list(id) return gr.update(), gr.update()