Spaces:
Sleeping
Sleeping
File size: 1,137 Bytes
b05b5f6 44c9388 73e160a b05b5f6 73e160a b05b5f6 44c9388 b05b5f6 44c9388 b05b5f6 44c9388 b05b5f6 44c9388 |
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 |
import streamlit as st
from transformers import pipeline
# Streamlit app title
st.title("Text to Speech Converter")
# User input for text to convert to speech
text_input = st.text_area("Enter text to convert to speech:")
# Load the Hugging Face TTS model
# Using a more reliable and commonly used model for TTS
tts_pipeline = pipeline("text-to-speech", model="microsoft/speecht5_tts")
from datasets import load_dataset
ds = load_dataset("Matthijs/cmu-arctic-xvectors")
# Button to generate speech
if st.button("Convert to Speech"):
if text_input:
# Generate the speech
tts_output = tts_pipeline(text_input)
# The output from the pipeline should be an array of speech chunks
# Save the generated speech to a file
audio_file_path = "output.wav"
with open(audio_file_path, "wb") as f:
f.write(tts_output[0]["array"])
# Display the audio player in Streamlit
st.audio(audio_file_path)
else:
st.warning("Please enter some text to convert.")
# Footer
st.markdown("Powered by [Hugging Face Transformers](https://huggingface.co/transformers/).")
|