Spaces:
Running
Running
fix
Browse files- ragg/app.py +23 -5
ragg/app.py
CHANGED
|
@@ -89,19 +89,37 @@ def xtts_speak_to_file(
|
|
| 89 |
# gpu=False,
|
| 90 |
# )
|
| 91 |
if not hasattr(xtts_speak_to_file, "_model") or xtts_speak_to_file._model is None:
|
| 92 |
-
import sys
|
| 93 |
-
import
|
|
|
|
| 94 |
|
| 95 |
-
#
|
| 96 |
sys.stdin = open(os.devnull)
|
| 97 |
-
builtins.input = lambda *a, **kw: ""
|
| 98 |
-
os.environ["COQUI_TOS_AGREED"] = "1"
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
xtts_speak_to_file._model = TTS(
|
| 101 |
model_name="tts_models/multilingual/multi-dataset/xtts_v2",
|
| 102 |
gpu=False,
|
| 103 |
progress_bar=False,
|
| 104 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
tts = xtts_speak_to_file._model
|
| 106 |
|
| 107 |
out_path = Path(out_file) if out_file else Path(f"xtts_{uuid.uuid4().hex}.wav")
|
|
|
|
| 89 |
# gpu=False,
|
| 90 |
# )
|
| 91 |
if not hasattr(xtts_speak_to_file, "_model") or xtts_speak_to_file._model is None:
|
| 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 stdin / input errors on Hugging Face
|
| 97 |
sys.stdin = open(os.devnull)
|
| 98 |
+
builtins.input = lambda *a, **kw: ""
|
| 99 |
+
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 100 |
+
|
| 101 |
+
# Allowlist the XTTS config class for torch.load()
|
| 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 |
+
|
| 113 |
+
# # Force stdin to null and override input() globally
|
| 114 |
+
# sys.stdin = open(os.devnull)
|
| 115 |
+
# builtins.input = lambda *a, **kw: "" # prevents EOF when the model asks for input
|
| 116 |
+
# os.environ["COQUI_TOS_AGREED"] = "1" # XTTS sometimes asks this internally
|
| 117 |
+
|
| 118 |
+
# xtts_speak_to_file._model = TTS(
|
| 119 |
+
# model_name="tts_models/multilingual/multi-dataset/xtts_v2",
|
| 120 |
+
# gpu=False,
|
| 121 |
+
# progress_bar=False,
|
| 122 |
+
# )
|
| 123 |
tts = xtts_speak_to_file._model
|
| 124 |
|
| 125 |
out_path = Path(out_file) if out_file else Path(f"xtts_{uuid.uuid4().hex}.wav")
|