Spaces:
Sleeping
Sleeping
File size: 1,137 Bytes
3899ba5 98c10c3 3899ba5 98c10c3 cc14627 3899ba5 98c10c3 3899ba5 98c10c3 cc14627 98c10c3 3899ba5 98c10c3 cc14627 98c10c3 |
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 |
import streamlit as st
import asyncio
import edge_tts
from io import BytesIO
st.set_page_config(page_title="Realistic Text-to-Speech", layout="centered")
st.title("ποΈ AI Voice Generator (Human-like)")
text = st.text_area("Enter text to convert into human-like speech:")
voice = st.selectbox("Choose a voice:", [
"en-US-AriaNeural", # Female (US)
"en-US-GuyNeural", # Male (US)
"en-GB-LibbyNeural", # Female (UK)
"en-IN-NeerjaNeural", # Female (India)
"en-IN-PrabhatNeural", # Male (India)
])
if st.button("Generate Audio"):
if not text.strip():
st.warning("Please enter some text.")
else:
async def generate_tts():
communicate = edge_tts.Communicate(text, voice)
audio_data = BytesIO()
async for chunk in communicate.stream():
if chunk["type"] == "audio":
audio_data.write(chunk["data"])
audio_data.seek(0)
return audio_data
audio_file = asyncio.run(generate_tts())
st.audio(audio_file, format="audio/mp3")
st.success("β
Done! Play the audio above.")
|