pratikshahp commited on
Commit
251db9c
·
verified ·
1 Parent(s): 1732f3b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from espnet2.bin.tts_inference import Text2Speech
3
+
4
+ # Load the Text2Speech model
5
+ model = Text2Speech.from_pretrained("kan-bayashi/ljspeech_fastspeech2")
6
+
7
+ def generate_audio(text):
8
+ with st.spinner("Generating Speech..."):
9
+ speech, *_ = model(text)
10
+ return speech
11
+
12
+ def main():
13
+ st.title("Text to Speech with ESPnet2")
14
+
15
+ text_input = st.text_area("Enter the text to generate speech:", "")
16
+ if st.button("Generate Speech"):
17
+ if text_input:
18
+ audio = generate_audio(text_input)
19
+ st.audio(audio, format="audio/wav")
20
+ else:
21
+ st.warning("Please enter some text.")
22
+
23
+ if __name__ == "__main__":
24
+ main()