Spaces:
Runtime error
Runtime error
import streamlit as st | |
import edge_tts | |
import asyncio | |
async def tts(text, language): | |
tts = edge_tts.Communicate(text, voice=language) | |
await tts.save("output.mp3") | |
return "output.mp3" | |
def generate_tts(text, language): | |
return asyncio.run(tts(text, language)) | |
languages = { | |
"English": "en-US-JennyNeural", | |
"Indonesian": "id-ID-GadisNeural", | |
"Korean": "ko-KR-SunHiNeural", | |
"Japanese": "ja-JP-NanamiNeural", | |
"Malaysian": "ms-MY-OsmanNeural" | |
} | |
def get_audio_file(text, lang_key): | |
language = languages[lang_key] | |
return generate_tts(text, language) | |
st.title("Blane TTS") | |
text_input = st.text_area("Input Text") | |
language_input = st.selectbox("Select Language", list(languages.keys())) | |
tts_button = st.button("Generate TTS") | |
if tts_button: | |
audio_file = get_audio_file(text_input, language_input) | |
audio_bytes = open(audio_file, "rb").read() | |
st.audio(audio_bytes, format="audio/mp3") | |