Saanvi12011 commited on
Commit
878f47d
·
verified ·
1 Parent(s): 4788b01

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Initialize text-to-speech pipeline
5
+ tts_model = pipeline("text-to-speech", model="facebook/fastspeech2-en-ljspeech")
6
+
7
+ st.title("Text-to-Speech Generator")
8
+ st.write("Convert text into speech audio.")
9
+
10
+ text = st.text_area("Enter text to convert to speech:", placeholder="Type your text here...")
11
+ if st.button("Generate Speech"):
12
+ if not text.strip():
13
+ st.error("Please provide some text to convert.")
14
+ else:
15
+ with st.spinner("Generating speech..."):
16
+ audio = tts_model(text)
17
+ st.audio(audio["output"], format="audio/wav")