| import gradio as gr | |
| from processing import transcribe_translate_speak | |
| import tempfile | |
| def process(audio_file, language): | |
| with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tmp: | |
| tmp.write(audio_file.read()) | |
| tmp_path = tmp.name | |
| transcription, translation, audio_output = transcribe_translate_speak(tmp_path, language) | |
| return transcription, translation, audio_output | |
| iface = gr.Interface( | |
| fn=process, | |
| inputs=[ | |
| gr.Audio(type="filepath", label="Upload or Record Audio"), | |
| gr.Dropdown(["hin", "es", "fr", "bangla"], label="Translate To") | |
| ], | |
| outputs=[ | |
| gr.Textbox(label="Transcribed Text"), | |
| gr.Textbox(label="Translated Text"), | |
| gr.Audio(label="Translated Audio") | |
| ], | |
| title="🎙️ SpeechSync - Python Edition", | |
| description="Record your voice in English, and this app will transcribe, translate, and speak it in your chosen language." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |