Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from transformers import pipeline | |
| # Set up the text-to-speech pipeline with a compatible model | |
| pipe = pipeline('text-to-speech', 'Xenova/speecht5_tts'); | |
| def text_to_speech(text): | |
| result = pipe(text) | |
| audio_path = 'output.wav' | |
| with open(audio_path, 'wb') as f: | |
| f.write(result['audio']) | |
| return audio_path | |
| st.title("Text to Speech with Hugging Face Model") | |
| text = st.text_area("Enter text to convert to speech:") | |
| if st.button("Convert"): | |
| if text: | |
| audio_file = text_to_speech(text) | |
| audio_bytes = open(audio_file, 'rb').read() | |
| st.audio(audio_bytes, format='audio/wav') | |
| else: | |
| st.warning("Please enter some text.") | |