Working Piper! Voice clone, no default select for no voice clone

This commit is contained in:
DrewThomasson
2025-11-05 17:26:58 -05:00
parent f794c2e4b0
commit cf87d192bc
4 changed files with 21 additions and 15 deletions

View File

@@ -130,7 +130,7 @@ class Coqui:
try: try:
if key in loaded_tts.keys(): if key in loaded_tts.keys():
return loaded_tts[key]['engine'] return loaded_tts[key]['engine']
unload_tts(device, [self.tts_key, self.tts_vc_key]) unload_tts(device, [self.tts_key, self.tts_vc_key], self.tts_key)
with lock: with lock:
# Download the model files if needed # Download the model files if needed
model_file, config_file = self._download_model(model_path) model_file, config_file = self._download_model(model_path)
@@ -154,7 +154,7 @@ class Coqui:
try: try:
if key in loaded_tts.keys(): if key in loaded_tts.keys():
return loaded_tts[key]['engine'] return loaded_tts[key]['engine']
unload_tts(device, [self.tts_vc_key]) unload_tts(device, [self.tts_vc_key], self.tts_vc_key)
with lock: with lock:
try: try:
from TTS.api import TTS as CoquiAPI # Lazy import to avoid hard dependency if not needed from TTS.api import TTS as CoquiAPI # Lazy import to avoid hard dependency if not needed
@@ -257,7 +257,7 @@ class Coqui:
return loaded_tts[key]['engine'] return loaded_tts[key]['engine']
tts_engine = kwargs.get('tts_engine') tts_engine = kwargs.get('tts_engine')
device = kwargs.get('device') device = kwargs.get('device')
unload_tts(device, [self.tts_key]) unload_tts(device, [self.tts_key], self.tts_key)
with lock: with lock:
checkpoint_dir = kwargs.get('checkpoint_dir') checkpoint_dir = kwargs.get('checkpoint_dir')
model_file = os.path.join(checkpoint_dir, 'model.onnx') model_file = os.path.join(checkpoint_dir, 'model.onnx')

View File

@@ -11,19 +11,25 @@ class TTSManager:
def _build(self)->None: def _build(self)->None:
if self.session['tts_engine'] in TTS_ENGINES.values(): if self.session['tts_engine'] in TTS_ENGINES.values():
if self.session['tts_engine'] in [TTS_ENGINES['XTTSv2'],TTS_ENGINES['BARK'],TTS_ENGINES['VITS'],TTS_ENGINES['FAIRSEQ'],TTS_ENGINES['TACOTRON2'],TTS_ENGINES['YOURTTS']]: try:
from lib.classes.tts_engines.coqui import Coqui if self.session['tts_engine'] in [TTS_ENGINES['XTTSv2'],TTS_ENGINES['BARK'],TTS_ENGINES['VITS'],TTS_ENGINES['FAIRSEQ'],TTS_ENGINES['TACOTRON2'],TTS_ENGINES['YOURTTS']]:
self.engine = Coqui(self.session) from lib.classes.tts_engines.coqui import Coqui
elif self.session['tts_engine'] in [TTS_ENGINES['PIPER']]: self.engine = Coqui(self.session)
from lib.classes.tts_engines.piper import Coqui elif self.session['tts_engine'] in [TTS_ENGINES['PIPER']]:
self.tts = Coqui(self.session) from lib.classes.tts_engines.piper import Coqui as PiperCoqui
#elif self.session['tts_engine'] in [TTS_ENGINES['NEW_TTS']]: self.engine = PiperCoqui(self.session)
# from lib.classes.tts_engines.new_tts import NewTts #elif self.session['tts_engine'] in [TTS_ENGINES['NEW_TTS']]:
# self.engine = NewTts(self.session) # from lib.classes.tts_engines.new_tts import NewTts
if not self.engine.tts: # self.engine = NewTts(self.session)
self.engine = False
error='TTS engine could not be created!' # Check if engine was created successfully (not False)
if self.engine is False:
error='TTS engine could not be created!'
print(error)
except Exception as e:
error = f'_build() error: {e}'
print(error) print(error)
self.engine = False
else: else:
print('Other TTS engines coming soon!') print('Other TTS engines coming soon!')