Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,16 +4,16 @@ import edge_tts
|
|
| 4 |
from io import BytesIO
|
| 5 |
|
| 6 |
st.set_page_config(page_title="Realistic Text-to-Speech", layout="centered")
|
| 7 |
-
st.title("🎙️ AI Voice Generator (
|
| 8 |
|
| 9 |
text = st.text_area("Enter text to convert into human-like speech:")
|
| 10 |
|
| 11 |
voice = st.selectbox("Choose a voice:", [
|
| 12 |
-
"en-US-AriaNeural", # Female
|
| 13 |
-
"en-US-GuyNeural", # Male
|
| 14 |
-
"en-GB-LibbyNeural", #
|
| 15 |
-
"en-IN-NeerjaNeural", #
|
| 16 |
-
"en-IN-PrabhatNeural", #
|
| 17 |
])
|
| 18 |
|
| 19 |
if st.button("Generate Audio"):
|
|
@@ -22,10 +22,12 @@ if st.button("Generate Audio"):
|
|
| 22 |
else:
|
| 23 |
async def generate_tts():
|
| 24 |
communicate = edge_tts.Communicate(text, voice)
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
|
| 30 |
audio_file = asyncio.run(generate_tts())
|
| 31 |
st.audio(audio_file, format="audio/mp3")
|
|
|
|
| 4 |
from io import BytesIO
|
| 5 |
|
| 6 |
st.set_page_config(page_title="Realistic Text-to-Speech", layout="centered")
|
| 7 |
+
st.title("🎙️ AI Voice Generator (Human-like)")
|
| 8 |
|
| 9 |
text = st.text_area("Enter text to convert into human-like speech:")
|
| 10 |
|
| 11 |
voice = st.selectbox("Choose a voice:", [
|
| 12 |
+
"en-US-AriaNeural", # Female (US)
|
| 13 |
+
"en-US-GuyNeural", # Male (US)
|
| 14 |
+
"en-GB-LibbyNeural", # Female (UK)
|
| 15 |
+
"en-IN-NeerjaNeural", # Female (India)
|
| 16 |
+
"en-IN-PrabhatNeural", # Male (India)
|
| 17 |
])
|
| 18 |
|
| 19 |
if st.button("Generate Audio"):
|
|
|
|
| 22 |
else:
|
| 23 |
async def generate_tts():
|
| 24 |
communicate = edge_tts.Communicate(text, voice)
|
| 25 |
+
audio_data = BytesIO()
|
| 26 |
+
async for chunk in communicate.stream():
|
| 27 |
+
if chunk["type"] == "audio":
|
| 28 |
+
audio_data.write(chunk["data"])
|
| 29 |
+
audio_data.seek(0)
|
| 30 |
+
return audio_data
|
| 31 |
|
| 32 |
audio_file = asyncio.run(generate_tts())
|
| 33 |
st.audio(audio_file, format="audio/mp3")
|