Information
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
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
|
@@ -30,6 +31,7 @@ tts = TTS(model_name, gpu=torch.cuda.is_available())
|
|
30 |
tts.to(device_type)
|
31 |
|
32 |
def predict(prompt, language, gender, audio_file_pth, mic_file_path, use_mic):
|
|
|
33 |
if len(prompt) < 2:
|
34 |
gr.Warning("Please give a longer prompt text")
|
35 |
return (
|
@@ -37,13 +39,13 @@ def predict(prompt, language, gender, audio_file_pth, mic_file_path, use_mic):
|
|
37 |
None,
|
38 |
None,
|
39 |
)
|
40 |
-
if len(prompt)
|
41 |
gr.Warning("Text length limited to 50,000 characters for this demo, please try shorter text")
|
42 |
return (
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
if use_mic:
|
49 |
if mic_file_path is None:
|
@@ -80,12 +82,21 @@ def predict(prompt, language, gender, audio_file_pth, mic_file_path, use_mic):
|
|
80 |
else:
|
81 |
raise e
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
return (
|
84 |
gr.make_waveform(
|
85 |
audio="output.wav",
|
86 |
),
|
87 |
"output.wav",
|
88 |
-
|
89 |
)
|
90 |
|
91 |
@spaces.GPU(duration=60)
|
|
|
1 |
import sys
|
2 |
import os
|
3 |
+
import time
|
4 |
import torch
|
5 |
import spaces
|
6 |
# By using XTTS you agree to CPML license https://coqui.ai/cpml
|
|
|
31 |
tts.to(device_type)
|
32 |
|
33 |
def predict(prompt, language, gender, audio_file_pth, mic_file_path, use_mic):
|
34 |
+
start = time.time()
|
35 |
if len(prompt) < 2:
|
36 |
gr.Warning("Please give a longer prompt text")
|
37 |
return (
|
|
|
39 |
None,
|
40 |
None,
|
41 |
)
|
42 |
+
if 50000 < len(prompt):
|
43 |
gr.Warning("Text length limited to 50,000 characters for this demo, please try shorter text")
|
44 |
return (
|
45 |
+
None,
|
46 |
+
None,
|
47 |
+
None,
|
48 |
+
)
|
49 |
|
50 |
if use_mic:
|
51 |
if mic_file_path is None:
|
|
|
82 |
else:
|
83 |
raise e
|
84 |
|
85 |
+
end = time.time()
|
86 |
+
secondes = int(end - start)
|
87 |
+
minutes = math.floor(secondes / 60)
|
88 |
+
secondes = secondes - (minutes * 60)
|
89 |
+
hours = math.floor(minutes / 60)
|
90 |
+
minutes = minutes - (hours * 60)
|
91 |
+
is_randomize_seed = False
|
92 |
+
information = ("Start again to get a different result. " if is_randomize_seed else "") + "The sound has been generated in " + ((str(hours) + " h, ") if hours != 0 else "") + ((str(minutes) + " min, ") if hours != 0 or minutes != 0 else "") + str(secondes) + " sec."
|
93 |
+
|
94 |
return (
|
95 |
gr.make_waveform(
|
96 |
audio="output.wav",
|
97 |
),
|
98 |
"output.wav",
|
99 |
+
information,
|
100 |
)
|
101 |
|
102 |
@spaces.GPU(duration=60)
|