File size: 1,274 Bytes
df1a757
cc60a92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
df1a757
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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")