From c27ee3ce9540fa400a989ebe310d74a91cd4e4af Mon Sep 17 00:00:00 2001 From: mrq Date: Tue, 7 Mar 2023 17:04:45 +0000 Subject: [PATCH] added update checking for dlas and tortoise-tts, caching voices (for a given model and voice name) so random latents will remain the same --- src/utils.py | 22 +++++++++++++++++----- tortoise-tts | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/utils.py b/src/utils.py index f9ba59d..9a00c1c 100755 --- a/src/utils.py +++ b/src/utils.py @@ -103,8 +103,12 @@ def generate( if seed == 0: seed = None + voice_cache = {} def fetch_voice( voice ): - print(f"Loading voice: {voice}") + print(f"Loading voice: {voice} with model {tts.autoregressive_model_hash[:8]}") + cache_key = f'{voice}:{tts.autoregressive_model_hash[:8]}' + if cache_key in voice_cache: + return voice_cache[cache_key] sample_voice = None if voice == "microphone": @@ -126,7 +130,8 @@ def generate( sample_voice = torch.cat(voice_samples, dim=-1).squeeze().cpu() voice_samples = None - return (voice_samples, conditioning_latents, sample_voice) + voice_cache[cache_key] = (voice_samples, conditioning_latents, sample_voice) + return voice_cache[cache_key] def get_settings( override=None ): settings = { @@ -1479,12 +1484,19 @@ def curl(url): print(e) return None -def check_for_updates(): - if not os.path.isfile('./.git/FETCH_HEAD'): +def check_for_updates( dir = None ): + if dir is None: + check_for_updates("./") + check_for_updates("./dlas/") + check_for_updates("./tortoise-tts/") + return + + git_dir = f'{dir}/.git/' + if not os.path.isfile(f'{git_dir}/FETCH_HEAD'): print("Cannot check for updates: not from a git repo") return False - with open(f'./.git/FETCH_HEAD', 'r', encoding="utf-8") as f: + with open(f'{git_dir}/FETCH_HEAD', 'r', encoding="utf-8") as f: head = f.read() match = re.findall(r"^([a-f0-9]+).+?https:\/\/(.+?)\/(.+?)\/(.+?)\n", head) diff --git a/tortoise-tts b/tortoise-tts index 26133c2..cc36c09 160000 --- a/tortoise-tts +++ b/tortoise-tts @@ -1 +1 @@ -Subproject commit 26133c20314b77155e77be804b43909dab9809d6 +Subproject commit cc36c0997c8711889ef8028002fc9e41abd5c5f0