Spaces:
Runtime error
Runtime error
change structure of tts
Browse files
app.py
CHANGED
|
@@ -2,9 +2,7 @@ import tempfile
|
|
| 2 |
from typing import Optional
|
| 3 |
import gradio as gr
|
| 4 |
import numpy as np
|
| 5 |
-
from TTS.
|
| 6 |
-
from TTS.utils.manage import ModelManager
|
| 7 |
-
from TTS.utils.synthesizer import Synthesizer
|
| 8 |
|
| 9 |
MAX_TXT_LEN = 100
|
| 10 |
manager = ModelManager()
|
|
@@ -13,22 +11,23 @@ def generate_audio(text):
|
|
| 13 |
if len(text) > MAX_TXT_LEN:
|
| 14 |
text = text[:MAX_TXT_LEN]
|
| 15 |
print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
|
| 16 |
-
model_path, config_path, model_item = manager.download_model(model_name)
|
| 17 |
-
vocoder_name: Optional[str] = model_item["default_vocoder"]
|
| 18 |
-
vocoder_path = None
|
| 19 |
-
vocoder_config_path = None
|
| 20 |
-
if vocoder_name is not None:
|
| 21 |
-
|
| 22 |
-
synthesizer = Synthesizer(
|
| 23 |
-
|
| 24 |
-
)
|
| 25 |
-
if synthesizer is None:
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
| 32 |
|
| 33 |
iface = gr.Interface(
|
| 34 |
fn=generate_audio,
|
|
|
|
| 2 |
from typing import Optional
|
| 3 |
import gradio as gr
|
| 4 |
import numpy as np
|
| 5 |
+
from TTS.api import TTS
|
|
|
|
|
|
|
| 6 |
|
| 7 |
MAX_TXT_LEN = 100
|
| 8 |
manager = ModelManager()
|
|
|
|
| 11 |
if len(text) > MAX_TXT_LEN:
|
| 12 |
text = text[:MAX_TXT_LEN]
|
| 13 |
print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
|
| 14 |
+
# model_path, config_path, model_item = manager.download_model(model_name)
|
| 15 |
+
# vocoder_name: Optional[str] = model_item["default_vocoder"]
|
| 16 |
+
# vocoder_path = None
|
| 17 |
+
# vocoder_config_path = None
|
| 18 |
+
# if vocoder_name is not None:
|
| 19 |
+
# vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name)
|
| 20 |
+
# synthesizer = Synthesizer(
|
| 21 |
+
# model_path, config_path, None, None, vocoder_path, vocoder_config_path,
|
| 22 |
+
# )
|
| 23 |
+
# if synthesizer is None:
|
| 24 |
+
# raise NameError("model not found")
|
| 25 |
+
tts = TTS(model_name)
|
| 26 |
+
wav = tts.tts(text, speaker=tts.speakers[0], language=tts.languages[0])
|
| 27 |
+
return wav
|
| 28 |
+
# with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
| 29 |
+
# synthesizer.save_wav(wav, fp)
|
| 30 |
+
# return fp.name
|
| 31 |
|
| 32 |
iface = gr.Interface(
|
| 33 |
fn=generate_audio,
|