Description
Describe the bug
Trying to use Coqui-ai TTS in Jenkins job, and Im getting below err:
C:\ProgramData\Jenkins\.jenkins\workspace\Dziennik\scripts>python tts.py --input_text_file_path DU/2025/658 Traceback (most recent call last): File "C:\ProgramData\Jenkins\.jenkins\workspace\Dziennik\scripts\tts.py", line 34, in <module> api = TTS(model_name="tts_models/pl/mai_female/vits") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Ja\AppData\Local\Programs\Python\Python311\Lib\site-packages\TTS\api.py", line 64, in __init__ self.manager = ModelManager(models_file=self.get_models_file_path(), progress_bar=progress_bar, verbose=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Ja\AppData\Local\Programs\Python\Python311\Lib\site-packages\TTS\utils\manage.py", line 51, in __init__ self.output_prefix = get_user_data_dir("tts") ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Ja\AppData\Local\Programs\Python\Python311\Lib\site-packages\TTS\utils\generic_utils.py", line 139, in get_user_data_dir key = winreg.OpenKey( ^^^^^^^^^^^^^^^ FileNotFoundError: [WinError 2] Nie mo�na odnale�� okre�lonego pliku
This is the code which i use:
`from TTS.api import TTS
import torch
import io
import argparse
arg parser
parser = argparse.ArgumentParser()
parser.add_argument('--input_text_file_path', dest='input_text_file_path',
type=str, help='Add input_text_file_path')
args = parser.parse_args()
Save the original torch.load function
_original_torch_load = torch.load
Define a new function that forces weights_only=False
def custom_torch_load(*args, **kwargs):
if "weights_only" not in kwargs:
kwargs["weights_only"] = False
return _original_torch_load(*args, **kwargs)
Override torch.load globally
torch.load = custom_torch_load
def import_text_file(file_name):
with io.open(f"{file_name}.txt", 'r', encoding="utf-8") as file:
return file.read().replace('\n', '')
TTS with on the fly voice conversion
api = TTS(model_name="tts_models/pl/mai_female/vits")
api.tts_to_file(
text=import_text_file(args.input_text_file_path.replace('/', '')),
speaker_wav="target/speaker.wav",
file_path=f"{args.input_text_file_path.replace('/', '')}.wav"
)`
At the same time the code is working normally when i trigger it from the cmd, just when i use jenkins the issue show up.
Not able to find any proper workaround for this.
To Reproduce
.
Expected behavior
No response
Logs
Environment
TTS 0.22.0
Additional context
No response