feat: use facebook model for text to speech
Browse files
app.py
CHANGED
|
@@ -1,4 +1,19 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
|
| 3 |
+
import IPython.display as ipd
|
| 4 |
|
| 5 |
+
|
| 6 |
+
models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
|
| 7 |
+
"facebook/fastspeech2-en-ljspeech",
|
| 8 |
+
arg_overrides={"vocoder": "hifigan", "fp16": False}
|
| 9 |
+
)
|
| 10 |
+
model = models[0]
|
| 11 |
+
TTSHubInterface.update_cfg_with_data_cfg(cfg, task.data_cfg)
|
| 12 |
+
generator = task.build_generator(model, cfg)
|
| 13 |
+
|
| 14 |
+
text = "Hello, this is a test run."
|
| 15 |
+
|
| 16 |
+
sample = TTSHubInterface.get_model_input(task, text)
|
| 17 |
+
wav, rate = TTSHubInterface.get_prediction(task, model, generator, sample)
|
| 18 |
+
|
| 19 |
+
ipd.Audio(wav, rate=rate)
|