From e3b2cac18b2f3b2a70578bb000872812159d98fb Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Dec 2025 06:26:49 -0800 Subject: [PATCH 1/3] ... --- lib/classes/device_installer.py | 432 ++++++++++++++++---------------- 1 file changed, 217 insertions(+), 215 deletions(-) diff --git a/lib/classes/device_installer.py b/lib/classes/device_installer.py index 35df05cb..0e7bd258 100644 --- a/lib/classes/device_installer.py +++ b/lib/classes/device_installer.py @@ -72,7 +72,7 @@ class DeviceInstaller(): except Exception: return '' - def toolkit_version_parse(text:str)->Union[str, None]: + def lib_version_parse(text:str)->Union[str, None]: if not text: return None text = text.strip() @@ -377,222 +377,9 @@ class DeviceInstaller(): name = None tag = None - msg = '' arch = platform.machine().lower() - - # ============================================================ - # JETSON - # ============================================================ - if arch in ('aarch64','arm64') and (os.path.exists('/etc/nv_tegra_release') or 'tegra' in try_cmd('cat /proc/device-tree/compatible')): - raw = tegra_version() - jp_code, msg = jetpack_version(raw) - if jp_code in ['unsupported', 'unknown']: - pass - elif os.path.exists('/etc/nv_tegra_release'): - devices['JETSON']['found'] = True - name = 'jetson' - tag = f'jetson{jp_code}' - elif os.path.exists('/proc/device-tree/compatible'): - out = try_cmd('cat /proc/device-tree/compatible') - if 'tegra' in out: - devices['JETSON']['found'] = True - name = 'jetson' - tag = f'jetson{jp_code}' - else: - out = try_cmd('uname -a') - if 'tegra' in out: - msg = 'Jetson GPU detected but not(?) compatible' - - # ============================================================ - # ROCm - # ============================================================ - elif has_working_rocm() and has_amd_gpu_pci(): - version_out = '' - if os.name == 'posix': - for p in ( - '/opt/rocm/.info/version', - '/opt/rocm/version', - ): - if os.path.exists(p): - with open(p, 'r', encoding='utf-8', errors='ignore') as f: - version_out = f.read() - break - elif os.name == 'nt': - for env in ('ROCM_PATH', 'HIP_PATH'): - base = os.environ.get(env) - if base: - for p in ( - os.path.join(base, 'version'), - os.path.join(base, '.info', 'version'), - ): - if os.path.exists(p): - with open(p, 'r', encoding='utf-8', errors='ignore') as f: - version_out = f.read() - break - if version_out: - break - if not version_out: - msg = 'ROCm hardware detected but AMD ROCm base runtime not installed.' - else: - version_str = toolkit_version_parse(version_out) - cmp = toolkit_version_compare(version_str, rocm_version_range) - if cmp == -1: - msg = f'ROCm {version_str} < min {rocm_version_range["min"]}. Please upgrade.' - elif cmp == 1: - msg = f'ROCm {version_str} > max {rocm_version_range["max"]}. Falling back to CPU.' - elif cmp == 0: - devices['ROCM']['found'] = True - parts = version_str.split(".") - major = parts[0] - minor = parts[1] if len(parts) > 1 else 0 - name = 'rocm' - tag = f'rocm{major}{minor}' - else: - msg = 'ROCm GPU detected but not compatible or ROCm runtime is missing.' - - # ============================================================ - # CUDA - # ============================================================ - elif has_working_cuda() and (has_nvidia_gpu_pci() or is_wsl2()): - version_out = '' - msg = '' - # 1) CUDA RUNTIME detection - try: - import ctypes - libcudart = None - if os.name == "nt": - # Native Windows: CUDA runtime is a DLL - for dll in ( - "cudart64_130.dll", - "cudart64_121.dll", - "cudart64_120.dll", - "cudart64_118.dll", - "cudart64_117.dll", - "cudart64_116.dll", - "cudart64_115.dll", - ): - try: - libcudart = ctypes.CDLL(dll) - break - except OSError: - pass - else: - # Linux + WSL2 - libcudart = ctypes.CDLL("libcudart.so") - if not libcudart: - raise OSError - version = ctypes.c_int() - if libcudart.cudaRuntimeGetVersion(ctypes.byref(version)) == 0: - device_count = ctypes.c_int() - if libcudart.cudaGetDeviceCount(ctypes.byref(device_count)) == 0: - v = version.value - major = v // 1000 - minor = (v % 1000) // 10 - if device_count.value > 0: - version_out = f"{major}.{minor}" - else: - msg = f'Runtime present ({major}.{minor}) but no devices.' - except (OSError, AttributeError): - pass - # CUDA TOOLKIT detection (fallback only) - if not version_out: - if os.name == 'posix': - for p in ( - '/usr/local/cuda/version.json', - '/usr/local/cuda/version.txt', - ): - if os.path.exists(p): - with open(p, 'r', encoding='utf-8', errors='ignore') as f: - version_out = f.read() - break - elif os.name == 'nt': - cuda_path = os.environ.get('CUDA_PATH') - if cuda_path: - for p in ( - os.path.join(cuda_path, 'version.json'), - os.path.join(cuda_path, 'version.txt'), - ): - if os.path.exists(p): - with open(p, 'r', encoding='utf-8', errors='ignore') as f: - version_out = f.read() - break - if not version_out: - if not msg: - msg = 'CUDA Toolkit or Runtime not installed or hardware not detected.' - else: - version_str = toolkit_version_parse(version_out) - cmp = toolkit_version_compare(version_str, cuda_version_range) - if cmp == -1: - msg = f'CUDA {version_str} < min {cuda_version_range["min"]}. Please upgrade.' - elif cmp == 1: - msg = f'CUDA {version_str} > max {cuda_version_range["max"]}. Falling back to CPU.' - elif cmp == 0: - devices['CUDA']['found'] = True - parts = version_str.split(".") - major = parts[0] - minor = parts[1] if len(parts) > 1 else 0 - name = 'cuda' - tag = f'cu{major}{minor}' - else: - msg = 'Cuda GPU detected but not compatible or Cuda runtime is missing.' - - # ============================================================ - # INTEL XPU - # ============================================================ - elif has_working_xpu() and has_intel_gpu_pci(): - version_out = '' - if os.name == 'posix': - for p in ( - '/opt/intel/oneapi/version.txt', - '/opt/intel/oneapi/compiler/latest/version.txt', - '/opt/intel/oneapi/runtime/latest/version.txt', - ): - if os.path.exists(p): - with open(p, 'r', encoding='utf-8', errors='ignore') as f: - version_out = f.read() - break - elif os.name == 'nt': - oneapi_root = os.environ.get('ONEAPI_ROOT') - if oneapi_root: - for p in ( - os.path.join(oneapi_root, 'version.txt'), - os.path.join(oneapi_root, 'compiler', 'latest', 'version.txt'), - os.path.join(oneapi_root, 'runtime', 'latest', 'version.txt'), - ): - if os.path.exists(p): - with open(p, 'r', encoding='utf-8', errors='ignore') as f: - version_out = f.read() - break - if not version_out: - msg = 'Intel GPU detected but oneAPI toolkit version file not found.' - else: - version_str = toolkit_version_parse(version_out) - cmp = toolkit_version_compare(version_str, xpu_version_range) - if cmp == -1 or cmp == 1: - msg = f'XPU {version_str} out of supported range {xpu_version_range}. Falling back to CPU.' - elif cmp == 0: - devices['XPU']['found'] = True - name = 'xpu' - tag = 'xpu' - else: - msg = 'Intel GPU detected but Intel oneAPI Base Toolkit not installed.' - - # ============================================================ - # APPLE MPS - # ============================================================ - elif sys.platform == 'darwin' and arch in ('arm64', 'aarch64'): - devices['MPS']['found'] = True - name = 'mps' - tag = 'mps' - - # ============================================================ - # CPU - # ============================================================ - if tag is None: - name = 'cpu' - tag = 'cpu' - forced_tag = os.environ.get("DEVICE_TAG") + if forced_tag: tag_letters = re.match(r"[a-zA-Z]+", forced_tag) if tag_letters: @@ -601,6 +388,221 @@ class DeviceInstaller(): devices[name.upper()]['found'] = True tag = forced_tag msg = f'Hardware forced from DEVICE_TAG={tag}' + else: + msg = f'DEVICE_TAG not valid' + else: + # ============================================================ + # JETSON + # ============================================================ + if arch in ('aarch64','arm64') and (os.path.exists('/etc/nv_tegra_release') or 'tegra' in try_cmd('cat /proc/device-tree/compatible')): + raw = tegra_version() + jp_code, msg = jetpack_version(raw) + if jp_code in ['unsupported', 'unknown']: + pass + elif os.path.exists('/etc/nv_tegra_release'): + devices['JETSON']['found'] = True + name = 'jetson' + tag = f'jetson{jp_code}' + elif os.path.exists('/proc/device-tree/compatible'): + out = try_cmd('cat /proc/device-tree/compatible') + if 'tegra' in out: + devices['JETSON']['found'] = True + name = 'jetson' + tag = f'jetson{jp_code}' + else: + out = try_cmd('uname -a') + if 'tegra' in out: + msg = 'Jetson GPU detected but not(?) compatible' + + # ============================================================ + # ROCm + # ============================================================ + elif has_working_rocm() and has_amd_gpu_pci(): + version = '' + msg = '' + if os.name == 'posix': + for p in ( + '/opt/rocm/.info/version', + '/opt/rocm/version', + ): + if os.path.exists(p): + with open(p, 'r', encoding='utf-8', errors='ignore') as f: + version = f.read() + break + elif os.name == 'nt': + for env in ('ROCM_PATH', 'HIP_PATH'): + base = os.environ.get(env) + if base: + for p in ( + os.path.join(base, 'version'), + os.path.join(base, '.info', 'version'), + ): + if os.path.exists(p): + with open(p, 'r', encoding='utf-8', errors='ignore') as f: + v = f.read() + version = lib_version_parse(v) + break + if version: + break + if version: + cmp = toolkit_version_compare(version, rocm_version_range) + if cmp == -1: + msg = f'ROCm {version} < min {rocm_version_range["min"]}. Please upgrade.' + elif cmp == 1: + msg = f'ROCm {version} > max {rocm_version_range["max"]}. Falling back to CPU.' + elif cmp == 0: + devices['ROCM']['found'] = True + parts = version.split(".") + major = parts[0] + minor = parts[1] if len(parts) > 1 else 0 + name = 'rocm' + tag = f'rocm{major}{minor}' + else: + msg = 'ROCm GPU detected but not compatible or ROCm runtime is missing.' + else: + msg = 'ROCm hardware detected but AMD ROCm base runtime not installed.' + + # ============================================================ + # CUDA + # ============================================================ + elif has_working_cuda() and (has_nvidia_gpu_pci() or is_wsl2()): + version = '' + msg = '' + # 1) CUDA RUNTIME detection + try: + import ctypes + libcudart = None + if os.name == "nt": + min_major, min_minor = cuda_version_range["min"] + max_major, max_minor = cuda_version_range["max"] + for major in range(min_major, max_major + 1): + start_minor = min_minor if major == min_major else 0 + end_minor = max_minor if major == max_major else 9 + for minor in range(start_minor, end_minor + 1): + dll = f"cudart64_{major}{minor}.dll" + try: + libcudart = ctypes.CDLL(dll) + break + except OSError: + pass + if libcudart: + break + else: + # Linux + WSL2 + libcudart = ctypes.CDLL("libcudart.so") + if libcudart: + v_int = ctypes.c_int() + if libcudart.cudaRuntimeGetVersion(ctypes.byref(v_int)) == 0: + device_count = ctypes.c_int() + if libcudart.cudaGetDeviceCount(ctypes.byref(device_count)) == 0: + v = v_int.value + major = v // 1000 + minor = (v % 1000) // 10 + if device_count.value > 0: + version = f'{major}.{minor}' + else: + msg = f'Runtime present ({major}.{minor}) but no devices.' + except (OSError, AttributeError): + pass + # CUDA TOOLKIT detection (fallback only) + if not version: + if os.name == 'posix': + for p in ( + '/usr/local/cuda/version.json', + '/usr/local/cuda/version.txt', + ): + if os.path.exists(p): + with open(p, 'r', encoding='utf-8', errors='ignore') as f: + v = f.read() + version = lib_version_parse(v) + break + elif os.name == 'nt': + cuda_path = os.environ.get('CUDA_PATH') + if cuda_path: + for p in ( + os.path.join(cuda_path, 'version.json'), + os.path.join(cuda_path, 'version.txt'), + ): + if os.path.exists(p): + with open(p, 'r', encoding='utf-8', errors='ignore') as f: + v = f.read() + version = lib_version_parse(v) + break + if version: + cmp = toolkit_version_compare(version, cuda_version_range) + if cmp == -1: + msg = f'CUDA {version} < min {cuda_version_range["min"]}. Please upgrade.' + elif cmp == 1: + msg = f'CUDA {version} > max {cuda_version_range["max"]}. Falling back to CPU.' + elif cmp == 0: + devices['CUDA']['found'] = True + parts = version.split(".") + major = parts[0] + minor = parts[1] if len(parts) > 1 else 0 + name = 'cuda' + tag = f'cu{major}{minor}' + else: + msg = 'Cuda GPU detected but not compatible or Cuda runtime is missing.' + else: + msg = 'CUDA Toolkit or Runtime not installed or hardware not detected.' + + # ============================================================ + # INTEL XPU + # ============================================================ + elif has_working_xpu() and has_intel_gpu_pci(): + version = '' + msg = '' + if os.name == 'posix': + for p in ( + '/opt/intel/oneapi/version.txt', + '/opt/intel/oneapi/compiler/latest/version.txt', + '/opt/intel/oneapi/runtime/latest/version.txt', + ): + if os.path.exists(p): + with open(p, 'r', encoding='utf-8', errors='ignore') as f: + v = f.read() + version = lib_version_parse(v) + break + elif os.name == 'nt': + oneapi_root = os.environ.get('ONEAPI_ROOT') + if oneapi_root: + for p in ( + os.path.join(oneapi_root, 'version.txt'), + os.path.join(oneapi_root, 'compiler', 'latest', 'version.txt'), + os.path.join(oneapi_root, 'runtime', 'latest', 'version.txt'), + ): + if os.path.exists(p): + with open(p, 'r', encoding='utf-8', errors='ignore') as f: + v = f.read() + version = lib_version_parse(v) + break + if version: + cmp = toolkit_version_compare(version, xpu_version_range) + if cmp == -1 or cmp == 1: + msg = f'XPU {version} out of supported range {xpu_version_range}. Falling back to CPU.' + elif cmp == 0: + devices['XPU']['found'] = True + name = 'xpu' + tag = 'xpu' + else: + msg = 'Intel GPU detected but Intel oneAPI Base Toolkit not installed.' + else: + msg = 'Intel GPU detected but oneAPI toolkit version file not found.' + + # ============================================================ + # APPLE MPS + # ============================================================ + elif sys.platform == 'darwin' and arch in ('arm64', 'aarch64'): + devices['MPS']['found'] = True + name = 'mps' + tag = 'mps' + + # ============================================================ + # CPU + # ============================================================ + if tag is None: + name = 'cpu' + tag = 'cpu' name, tag, msg = (v.strip() if isinstance(v, str) else v for v in (name, tag, msg)) return (name, tag, msg) From 0f14ca5c6528cb8fe8327e4b86fbefefba18b5bb Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Dec 2025 06:30:51 -0800 Subject: [PATCH 2/3] ... --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index d8c2c1cb..fbbaaf9f 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -25.12.30 \ No newline at end of file +25.12.31 \ No newline at end of file From 1e9cfa340f999ba707e1475d50323270ee4311ac Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Dec 2025 06:47:34 -0800 Subject: [PATCH 3/3] ... --- lib/classes/tts_engines/bark.py | 5 ++--- lib/classes/tts_engines/common/utils.py | 3 +++ lib/classes/tts_engines/fairseq.py | 3 +++ lib/classes/tts_engines/tacotron.py | 3 +++ lib/classes/tts_engines/vits.py | 3 +++ lib/classes/tts_engines/xtts.py | 3 ++- lib/classes/tts_engines/yourtts.py | 5 ++--- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/classes/tts_engines/bark.py b/lib/classes/tts_engines/bark.py index b8f153d1..c8147fab 100644 --- a/lib/classes/tts_engines/bark.py +++ b/lib/classes/tts_engines/bark.py @@ -9,7 +9,6 @@ class Bark(TTSUtils, TTSRegistry, name='bark'): self.cache_dir = tts_dir self.speakers_path = None self.tts_key = self.session['model_cache'] - self.tts_zs_key = default_vc_model.rsplit('/',1)[-1] self.pth_voice_file = None self.sentences_total_time = 0.0 self.sentence_idx = 1 @@ -30,7 +29,6 @@ class Bark(TTSUtils, TTSRegistry, name='bark'): self._apply_cuda_policy(using_gpu=using_gpu, enough_vram=enough_vram, seed=seed) self.xtts_speakers = self._load_xtts_builtin_list() self.engine = self._load_engine() - self.engine_zs = self._load_engine_zs() except Exception as e: error = f'__init__() error: {e}' raise ValueError(error) @@ -123,7 +121,6 @@ class Bark(TTSUtils, TTSRegistry, name='bark'): print(msg) return False if self.engine: - device = devices['CUDA']['proc'] if self.session['device'] in ['cuda', 'jetson'] else self.session['device'] final_sentence_file = os.path.join(self.session['chapters_dir_sentences'], f'{sentence_index}.{default_audio_proc_format}') if sentence == TTS_SML['break']: silence_time = int(np.random.uniform(0.3, 0.6) * 100) / 100 @@ -186,6 +183,7 @@ class Bark(TTSUtils, TTSRegistry, name='bark'): **fine_tuned_params ) """ + device = devices['CUDA']['proc'] if self.session['device'] in ['cuda', 'jetson'] else self.session['device'] self.engine.to(device) audio_sentence = self.engine.tts( text=sentence, @@ -194,6 +192,7 @@ class Bark(TTSUtils, TTSRegistry, name='bark'): **tts_dyn_params, **fine_tuned_params ) + self.engine.to('cpu') if is_audio_data_valid(audio_sentence): src_tensor = self._tensor_type(audio_sentence) audio_tensor = src_tensor.clone().detach().unsqueeze(0).cpu() diff --git a/lib/classes/tts_engines/common/utils.py b/lib/classes/tts_engines/common/utils.py index 50a9c1b4..99ae8e6a 100644 --- a/lib/classes/tts_engines/common/utils.py +++ b/lib/classes/tts_engines/common/utils.py @@ -203,6 +203,8 @@ class TTSUtils: if self.session.get(key) is not None } with torch.no_grad(): + device = devices['CUDA']['proc'] if self.session['device'] in ['cuda', 'jetson'] else self.session['device'] + engine.to(device) result = engine.inference( text=default_text.strip(), language=self.session['language_iso1'], @@ -210,6 +212,7 @@ class TTSUtils: speaker_embedding=speaker_embedding, **fine_tuned_params, ) + engine.to('cpu') audio_sentence = result.get('wav') if is_audio_data_valid(audio_sentence): sourceTensor = self._tensor_type(audio_sentence) diff --git a/lib/classes/tts_engines/fairseq.py b/lib/classes/tts_engines/fairseq.py index 2c5f5d97..279d3b38 100644 --- a/lib/classes/tts_engines/fairseq.py +++ b/lib/classes/tts_engines/fairseq.py @@ -107,6 +107,7 @@ class Fairseq(TTSUtils, TTSRegistry, name='fairseq'): file_path=tmp_in_wav, **speaker_argument ) + self.engine.to('cpu') if self.params['voice_path'] in self.params['semitones'].keys(): semitones = self.params['semitones'][self.params['voice_path']] else: @@ -150,6 +151,7 @@ class Fairseq(TTSUtils, TTSRegistry, name='fairseq'): source_wav=source_wav, target_wav=target_wav ) + self.engine_zs.to('cpu') else: error = f'Engine {self.tts_zs_key} is None' print(error) @@ -167,6 +169,7 @@ class Fairseq(TTSUtils, TTSRegistry, name='fairseq'): text=re.sub(not_supported_punc_pattern, ' ', sentence), **speaker_argument ) + self.engine.to('cpu') if is_audio_data_valid(audio_sentence): src_tensor = self._tensor_type(audio_sentence) audio_tensor = src_tensor.clone().detach().unsqueeze(0).cpu() diff --git a/lib/classes/tts_engines/tacotron.py b/lib/classes/tts_engines/tacotron.py index 0347c8e6..6095a59c 100644 --- a/lib/classes/tts_engines/tacotron.py +++ b/lib/classes/tts_engines/tacotron.py @@ -135,6 +135,7 @@ class Tacotron2(TTSUtils, TTSRegistry, name='tacotron'): file_path=tmp_in_wav, **speaker_argument ) + self.engine.to('cpu') if self.params['voice_path'] in self.params['semitones'].keys(): semitones = self.params['semitones'][self.params['voice_path']] else: @@ -178,6 +179,7 @@ class Tacotron2(TTSUtils, TTSRegistry, name='tacotron'): source_wav=source_wav, target_wav=target_wav ) + self.engine_zs.to('cpu') else: error = f'Engine {self.tts_zs_key} is None' print(error) @@ -195,6 +197,7 @@ class Tacotron2(TTSUtils, TTSRegistry, name='tacotron'): text=re.sub(not_supported_punc_pattern, ' ', sentence), **speaker_argument ) + self.engine.to('cpu') if is_audio_data_valid(audio_sentence): src_tensor = self._tensor_type(audio_sentence) audio_tensor = src_tensor.clone().detach().unsqueeze(0).cpu() diff --git a/lib/classes/tts_engines/vits.py b/lib/classes/tts_engines/vits.py index e04be172..40c3c534 100644 --- a/lib/classes/tts_engines/vits.py +++ b/lib/classes/tts_engines/vits.py @@ -120,6 +120,7 @@ class Vits(TTSUtils, TTSRegistry, name='vits'): file_path=tmp_in_wav, **speaker_argument ) + self.engine.to('cpu') if self.params['voice_path'] in self.params['semitones'].keys(): semitones = self.params['semitones'][self.params['voice_path']] else: @@ -163,6 +164,7 @@ class Vits(TTSUtils, TTSRegistry, name='vits'): source_wav=source_wav, target_wav=target_wav ) + self.engine_zs.to('cpu') else: error = f'Engine {self.tts_zs_key} is None' print(error) @@ -180,6 +182,7 @@ class Vits(TTSUtils, TTSRegistry, name='vits'): text=sentence, **speaker_argument ) + self.engine.to('cpu') if is_audio_data_valid(audio_sentence): src_tensor = self._tensor_type(audio_sentence) audio_tensor = src_tensor.clone().detach().unsqueeze(0).cpu() diff --git a/lib/classes/tts_engines/xtts.py b/lib/classes/tts_engines/xtts.py index 42d8738e..57b50ce3 100644 --- a/lib/classes/tts_engines/xtts.py +++ b/lib/classes/tts_engines/xtts.py @@ -84,7 +84,6 @@ class XTTSv2(TTSUtils, TTSRegistry, name='xtts'): print(msg) return False if self.engine: - device = devices['CUDA']['proc'] if self.session['device'] in ['cuda', 'jetson'] else self.session['device'] final_sentence_file = os.path.join(self.session['chapters_dir_sentences'], f'{sentence_index}.{default_audio_proc_format}') if sentence == TTS_SML['break']: silence_time = int(np.random.uniform(0.3, 0.6) * 100) / 100 @@ -131,6 +130,7 @@ class XTTSv2(TTSUtils, TTSRegistry, name='xtts'): if self.session.get(key) is not None } with torch.no_grad(): + device = devices['CUDA']['proc'] if self.session['device'] in ['cuda', 'jetson'] else self.session['device'] self.engine.to(device) result = self.engine.inference( text=sentence, @@ -139,6 +139,7 @@ class XTTSv2(TTSUtils, TTSRegistry, name='xtts'): speaker_embedding=self.params['speaker_embedding'], **fine_tuned_params ) + self.engine.to('cpu') audio_sentence = result.get('wav') if is_audio_data_valid(audio_sentence): src_tensor = self._tensor_type(audio_sentence) diff --git a/lib/classes/tts_engines/yourtts.py b/lib/classes/tts_engines/yourtts.py index 9f03793d..18db70e3 100644 --- a/lib/classes/tts_engines/yourtts.py +++ b/lib/classes/tts_engines/yourtts.py @@ -9,7 +9,6 @@ class YourTTS(TTSUtils, TTSRegistry, name='yourtts'): self.cache_dir = tts_dir self.speakers_path = None self.tts_key = self.session['model_cache'] - self.tts_zs_key = default_vc_model.rsplit('/',1)[-1] self.pth_voice_file = None self.sentences_total_time = 0.0 self.sentence_idx = 1 @@ -30,7 +29,6 @@ class YourTTS(TTSUtils, TTSRegistry, name='yourtts'): self._apply_cuda_policy(using_gpu=using_gpu, enough_vram=enough_vram, seed=seed) self.xtts_speakers = self._load_xtts_builtin_list() self.engine = self._load_engine() - self.engine_zs = self._load_engine_zs() except Exception as e: error = f'__init__() error: {e}' raise ValueError(error) @@ -75,7 +73,6 @@ class YourTTS(TTSUtils, TTSRegistry, name='yourtts'): print(msg) return False if self.engine: - device = devices['CUDA']['proc'] if self.session['device'] in ['cuda', 'jetson'] else self.session['device'] final_sentence_file = os.path.join(self.session['chapters_dir_sentences'], f'{sentence_index}.{default_audio_proc_format}') if sentence == TTS_SML['break']: silence_time = int(np.random.uniform(0.3, 0.6) * 100) / 100 @@ -102,12 +99,14 @@ class YourTTS(TTSUtils, TTSRegistry, name='yourtts'): voice_key = default_engine_settings[self.session['tts_engine']]['voices']['ElectroMale-2'] speaker_argument = {"speaker": voice_key} with torch.no_grad(): + device = devices['CUDA']['proc'] if self.session['device'] in ['cuda', 'jetson'] else self.session['device'] self.engine.to(device) audio_sentence = self.engine.tts( text=re.sub(not_supported_punc_pattern, ' ', sentence), language=language, **speaker_argument ) + self.engine.to('cpu') if is_audio_data_valid(audio_sentence): src_tensor = self._tensor_type(audio_sentence) audio_tensor = src_tensor.clone().detach().unsqueeze(0).cpu()