From 68f3c2f2695f7d74c7fbf79e080f5a2ec82d33be Mon Sep 17 00:00:00 2001 From: Mozer Date: Sun, 10 Mar 2024 13:48:39 +0300 Subject: [PATCH] Add files via upload --- xtts/xtts_api_server/patch_xtts_api_server.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xtts/xtts_api_server/patch_xtts_api_server.py b/xtts/xtts_api_server/patch_xtts_api_server.py index f60e5585b9a..529ab07ddbe 100644 --- a/xtts/xtts_api_server/patch_xtts_api_server.py +++ b/xtts/xtts_api_server/patch_xtts_api_server.py @@ -4,7 +4,18 @@ def return_patch_files(): file_paths_with_replacements = [ ['server.py', - {'language = request.language[0:2]': """language = request.language[0:2] + {'speaker_wav = XTTS.get_speaker_wav(request.speaker_wav)': """# if voice not found -> use first found + folder_path = "speakers/" + if not os.path.isfile(folder_path+request.speaker_wav+".wav"): + files = [ f for f in os.listdir(folder_path) if os.path.isfile(os.path.join(folder_path,f)) and f.endswith(".wav") ] + if len(files) < 1: + print("Error: no files in /speakers. Put some wavs there.") + else: + filename = files[0].replace(".wav", "") + print(" ["+request.speaker_wav+" not found, using "+filename+"]") + request.speaker_wav = filename + print('\033[1m' + request.speaker_wav+'\033[0m: ' + request.text) + speaker_wav = XTTS.get_speaker_wav(request.speaker_wav) # CHECK: dont play if user is talking if STREAM_PLAY_SYNC: