Spaces:
Running
Running
fix
Browse files- ragg/app.py +23 -3
ragg/app.py
CHANGED
|
@@ -92,21 +92,41 @@ def xtts_speak_to_file(
|
|
| 92 |
import sys, builtins, torch
|
| 93 |
from torch.serialization import add_safe_globals
|
| 94 |
from TTS.tts.configs.xtts_config import XttsConfig
|
|
|
|
| 95 |
|
| 96 |
-
# Prevent
|
| 97 |
sys.stdin = open(os.devnull)
|
| 98 |
builtins.input = lambda *a, **kw: ""
|
| 99 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 100 |
|
| 101 |
-
# Allowlist
|
| 102 |
-
add_safe_globals([XttsConfig])
|
| 103 |
|
|
|
|
| 104 |
xtts_speak_to_file._model = TTS(
|
| 105 |
model_name="tts_models/multilingual/multi-dataset/xtts_v2",
|
| 106 |
gpu=False,
|
| 107 |
progress_bar=False,
|
| 108 |
)
|
| 109 |
# if not hasattr(xtts_speak_to_file, "_model") or xtts_speak_to_file._model is None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
# import sys
|
| 111 |
# import builtins
|
| 112 |
|
|
|
|
| 92 |
import sys, builtins, torch
|
| 93 |
from torch.serialization import add_safe_globals
|
| 94 |
from TTS.tts.configs.xtts_config import XttsConfig
|
| 95 |
+
from TTS.tts.models.xtts import XttsAudioConfig
|
| 96 |
|
| 97 |
+
# Prevent interactive prompts and stdin errors on Hugging Face
|
| 98 |
sys.stdin = open(os.devnull)
|
| 99 |
builtins.input = lambda *a, **kw: ""
|
| 100 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 101 |
|
| 102 |
+
# Allowlist XTTS internal classes for PyTorch 2.6+
|
| 103 |
+
add_safe_globals([XttsConfig, XttsAudioConfig])
|
| 104 |
|
| 105 |
+
# Instantiate XTTS safely
|
| 106 |
xtts_speak_to_file._model = TTS(
|
| 107 |
model_name="tts_models/multilingual/multi-dataset/xtts_v2",
|
| 108 |
gpu=False,
|
| 109 |
progress_bar=False,
|
| 110 |
)
|
| 111 |
# if not hasattr(xtts_speak_to_file, "_model") or xtts_speak_to_file._model is None:
|
| 112 |
+
# import sys, builtins, torch
|
| 113 |
+
# from torch.serialization import add_safe_globals
|
| 114 |
+
# from TTS.tts.configs.xtts_config import XttsConfig
|
| 115 |
+
|
| 116 |
+
# # Prevent stdin / input errors on Hugging Face
|
| 117 |
+
# sys.stdin = open(os.devnull)
|
| 118 |
+
# builtins.input = lambda *a, **kw: ""
|
| 119 |
+
# os.environ["COQUI_TOS_AGREED"] = "1"
|
| 120 |
+
|
| 121 |
+
# # Allowlist the XTTS config class for torch.load()
|
| 122 |
+
# add_safe_globals([XttsConfig])
|
| 123 |
+
|
| 124 |
+
# xtts_speak_to_file._model = TTS(
|
| 125 |
+
# model_name="tts_models/multilingual/multi-dataset/xtts_v2",
|
| 126 |
+
# gpu=False,
|
| 127 |
+
# progress_bar=False,
|
| 128 |
+
# )
|
| 129 |
+
# if not hasattr(xtts_speak_to_file, "_model") or xtts_speak_to_file._model is None:
|
| 130 |
# import sys
|
| 131 |
# import builtins
|
| 132 |
|