ZeroGPU
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
import torch
|
|
|
|
| 4 |
# By using XTTS you agree to CPML license https://coqui.ai/cpml
|
| 5 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 6 |
|
|
@@ -50,7 +51,7 @@ def predict(prompt, language, audio_file_pth, mic_file_path, use_mic):
|
|
| 50 |
None,
|
| 51 |
)
|
| 52 |
if len(prompt) > 50000:
|
| 53 |
-
gr.Warning("Text length limited to
|
| 54 |
return (
|
| 55 |
None,
|
| 56 |
None,
|
|
@@ -62,12 +63,7 @@ def predict(prompt, language, audio_file_pth, mic_file_path, use_mic):
|
|
| 62 |
language = "fr-fr"
|
| 63 |
if m.find("/fr/") != -1:
|
| 64 |
language = None
|
| 65 |
-
|
| 66 |
-
text=prompt,
|
| 67 |
-
file_path="output.wav",
|
| 68 |
-
speaker_wav=speaker_wav,
|
| 69 |
-
language=language
|
| 70 |
-
)
|
| 71 |
except RuntimeError as e :
|
| 72 |
if "device-assert" in str(e):
|
| 73 |
# cannot do anything on cuda device side error, need to restart
|
|
@@ -85,6 +81,15 @@ def predict(prompt, language, audio_file_pth, mic_file_path, use_mic):
|
|
| 85 |
None,
|
| 86 |
)
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
with gr.Blocks() as interface:
|
| 89 |
gr.HTML("Multi-language Text-to-Speech")
|
| 90 |
gr.HTML(
|
|
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
import torch
|
| 4 |
+
import spaces
|
| 5 |
# By using XTTS you agree to CPML license https://coqui.ai/cpml
|
| 6 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 7 |
|
|
|
|
| 51 |
None,
|
| 52 |
)
|
| 53 |
if len(prompt) > 50000:
|
| 54 |
+
gr.Warning("Text length limited to 50,000 characters for this demo, please try shorter text")
|
| 55 |
return (
|
| 56 |
None,
|
| 57 |
None,
|
|
|
|
| 63 |
language = "fr-fr"
|
| 64 |
if m.find("/fr/") != -1:
|
| 65 |
language = None
|
| 66 |
+
predict_on_gpu(prompt, peaker_wav, language)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
except RuntimeError as e :
|
| 68 |
if "device-assert" in str(e):
|
| 69 |
# cannot do anything on cuda device side error, need to restart
|
|
|
|
| 81 |
None,
|
| 82 |
)
|
| 83 |
|
| 84 |
+
@spaces.GPU(duration=60)
|
| 85 |
+
def predict_on_gpu(prompt, peaker_wav, language):
|
| 86 |
+
tts.tts_to_file(
|
| 87 |
+
text=prompt,
|
| 88 |
+
file_path="output.wav",
|
| 89 |
+
speaker_wav=speaker_wav,
|
| 90 |
+
language=language
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
with gr.Blocks() as interface:
|
| 94 |
gr.HTML("Multi-language Text-to-Speech")
|
| 95 |
gr.HTML(
|