Thorsten-Voice commited on
Commit
cc60a92
1 Parent(s): aadee0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -2
app.py CHANGED
@@ -1,4 +1,38 @@
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- print("Das ist ein normaler Text")
4
- text = st.text_area("Enter text here")
 
1
  import streamlit as st
2
+ import tempfile
3
+ from typing import Optional
4
+ from TTS.config import load_config
5
+ import numpy as np
6
+ from TTS.utils.manage import ModelManager
7
+ from TTS.utils.synthesizer import Synthesizer
8
+
9
+ st.title("Demo Thorsten-Voice")
10
+ st.header("Eine kostenlose, deutsche ...")
11
+
12
+ text = st.text_area("Zu sprechender Text",max_chars=100)
13
+ model = st.radio("Welches Thorsten-Voice Modell möchtest Du testen?",
14
+ ('Thorsten-VITS','Thorsten-DDC'))
15
+
16
+ # Load Thorsten-Voice TTS/Vocoder models
17
+ # Thanks to Coqui for inspiration and code snipplets :-)
18
+ manager = ModelManager()
19
+ model_path, config_path, model_item = manager.download_model("tts_models/de/thorsten/vits")
20
+ vocoder_name: Optional[str] = model_item["default_vocoder"]
21
+ vocoder_path = None
22
+ vocoder_config_path = None
23
+ if vocoder_name is not None:
24
+ vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name)
25
+
26
+ synthesizer = Synthesizer(
27
+ model_path, config_path, None, None, vocoder_path, vocoder_config_path,)
28
+
29
+ if text:
30
+ wav = synthesizer.tts(text)
31
+ filename = tempfile.NamedTemporaryFile(suffix=".wav", delete=False)
32
+ synthesizer.save_wav(wav, filename)
33
+
34
+ audio_file = open(filename.name, 'rb')
35
+ audio_bytes = audio_file.read()
36
+
37
+ st.audio(audio_bytes,format="audio/wav")
38