Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import sys
|
| 2 |
from pathlib import Path
|
| 3 |
|
|
@@ -11,10 +12,15 @@ from TTS.api import TTS
|
|
| 11 |
|
| 12 |
try:
|
| 13 |
from TTS.tts.utils.monotonic_align import core as _monotonic_align_core # noqa: F401
|
| 14 |
-
except ImportError
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# Get device
|
| 20 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
import sys
|
| 3 |
from pathlib import Path
|
| 4 |
|
|
|
|
| 12 |
|
| 13 |
try:
|
| 14 |
from TTS.tts.utils.monotonic_align import core as _monotonic_align_core # noqa: F401
|
| 15 |
+
except ImportError:
|
| 16 |
+
build_cmd = [sys.executable, "setup.py", "build_ext", "--inplace"]
|
| 17 |
+
subprocess.run(build_cmd, cwd=APP_ROOT, check=True)
|
| 18 |
+
try:
|
| 19 |
+
from TTS.tts.utils.monotonic_align import core as _monotonic_align_core # noqa: F401
|
| 20 |
+
except ImportError as exc:
|
| 21 |
+
raise RuntimeError(
|
| 22 |
+
"Failed to build monotonic_align extension; ensure build dependencies are installed."
|
| 23 |
+
) from exc
|
| 24 |
|
| 25 |
# Get device
|
| 26 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|