import streamlit as st
from gtts import gTTS
import base64
# Set up the page config
st.set_page_config(page_title="i love with Ali Languages", page_icon="🗣️")
# Custom CSS to hide any default Streamlit download options if they appear
st.markdown("""
""", unsafe_allow_html=True)
# Application Title
st.title("🗣️ i love with Ali Languages")
st.subheader("Gemini 3.1 Flash TTS Replica")
st.write("Enter your text, select a language, and listen to the generation instantly.")
---
# Language Selection Dictionary
languages = {
"English": "en",
"Arabic": "ar",
"Urdu": "ur",
"Spanish": "es",
"French": "fr",
"Hindi": "hi",
"Chinese": "zh"
}
# Layout UI
text_input = st.text_area("Enter text to convert to speech:", "Hello! Welcome to Ali Languages TTS replica.")
selected_lang = st.selectbox("Choose a Language:", list(languages.keys()))
if st.button("Generate TTS"):
if text_input.strip() == "":
st.error("Please enter some text first!")
else:
with st.spinner("Generating flash audio..."):
try:
# Process Text to Speech (Standard TTS, No Voice Cloning)
tts = gTTS(text=text_input, lang=languages[selected_lang], slow=False)
# Save as standard MP3 in system memory/temp
audio_file = "output.mp3"
tts.save(audio_file)
# Read audio to embed directly into the HTML player (Bypassing download buttons)
with open(audio_file, "rb") as f:
audio_bytes = f.read()
audio_base64 = base64.b64encode(audio_bytes).decode()
# Custom HTML Audio Player without the 'download' attribute or controls download option
audio_player = f"""
"""
st.success("Audio generated successfully!")
st.markdown(audio_player, unsafe_allow_html=True)
except Exception as e:
st.error(f"An error occurred: {e}")
---
st.caption("Note: Voice cloning and direct file downloads are disabled by design in this version.")