Spaces:
Running
Running
import streamlit as st | |
import tempfile | |
from typing import Optional | |
from TTS.config import load_config | |
import numpy as np | |
from TTS.utils.manage import ModelManager | |
from TTS.utils.synthesizer import Synthesizer | |
st.title("Demo Thorsten-Voice") | |
st.header("Eine kostenlose, deutsche ...") | |
text = st.text_area("Zu sprechender Text",max_chars=100) | |
model = st.radio("Welches Thorsten-Voice Modell möchtest Du testen?", | |
('Thorsten-VITS','Thorsten-DDC')) | |
# Load Thorsten-Voice TTS/Vocoder models | |
# Thanks to Coqui for inspiration and code snipplets :-) | |
manager = ModelManager() | |
model_path, config_path, model_item = manager.download_model("tts_models/de/thorsten/vits") | |
vocoder_name: Optional[str] = model_item["default_vocoder"] | |
vocoder_path = None | |
vocoder_config_path = None | |
if vocoder_name is not None: | |
vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name) | |
synthesizer = Synthesizer( | |
model_path, config_path, None, None, vocoder_path, vocoder_config_path,) | |
if text: | |
wav = synthesizer.tts(text) | |
filename = tempfile.NamedTemporaryFile(suffix=".wav", delete=False) | |
synthesizer.save_wav(wav, filename) | |
audio_file = open(filename.name, 'rb') | |
audio_bytes = audio_file.read() | |
st.audio(audio_bytes,format="audio/wav") | |