Ahsan658 commited on
Commit
b05b5f6
·
verified ·
1 Parent(s): 73ac36f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Streamlit app title
5
+ st.title("Text to Speech Converter")
6
+
7
+ # User input for text to convert to speech
8
+ text_input = st.text_area("Enter text to convert to speech:")
9
+
10
+ # Load the Hugging Face TTS model
11
+ tts_pipeline = pipeline("text-to-speech", model="espnet/kan-bayashi-ljspeech-vits")
12
+
13
+ # Button to generate speech
14
+ if st.button("Convert to Speech"):
15
+ if text_input:
16
+ # Generate the speech
17
+ tts_output = tts_pipeline(text_input)
18
+
19
+ # Save the generated speech to a file
20
+ with open("output.wav", "wb") as f:
21
+ f.write(tts_output["wav"])
22
+
23
+ # Display the audio player in Streamlit
24
+ st.audio("output.wav")
25
+ else:
26
+ st.warning("Please enter some text to convert.")
27
+
28
+ # Footer
29
+ st.markdown("Powered by [Hugging Face Transformers](https://huggingface.co/transformers/).")