import gradio as gr from gtts import gTTS from io import BytesIO def text_to_speech(text, language="en"): """ Convert text to speech using gTTS and return the audio file. """ try: if not text.strip(): return "Error: Please enter valid text.", None # Generate the speech using gTTS tts = gTTS(text=text, lang=language) audio_file = BytesIO() tts.write_to_fp(audio_file) audio_file.seek(0) return "Text-to-Speech conversion successful!", audio_file except Exception as e: return f"Error: {str(e)}", None # HTML content with animations, styling, and JavaScript html_content = """