Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,88 +112,21 @@ def process_translation(api_key, english_text):
|
|
| 112 |
|
| 113 |
return "Translation Successful!", translated_text, cleaned_pronunciation, result_file_name, audio_path
|
| 114 |
|
| 115 |
-
|
| 116 |
-
#
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
gr.
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
</p>
|
| 133 |
-
</div>
|
| 134 |
-
<hr>
|
| 135 |
-
"""
|
| 136 |
-
)
|
| 137 |
-
|
| 138 |
-
# 🔹 Layout Section
|
| 139 |
-
with gr.Row():
|
| 140 |
-
# Left side - Input
|
| 141 |
-
with gr.Column(scale=1, min_width=400):
|
| 142 |
-
gr.Markdown("### ✏️ Input Section")
|
| 143 |
-
api_key = gr.Textbox(
|
| 144 |
-
label="🔑 Gemini API Key",
|
| 145 |
-
type="password",
|
| 146 |
-
placeholder="Enter your Gemini API key here..."
|
| 147 |
-
)
|
| 148 |
-
english_text = gr.Textbox(
|
| 149 |
-
label="📝 English Text",
|
| 150 |
-
lines=5,
|
| 151 |
-
placeholder="Type something in English to translate..."
|
| 152 |
-
)
|
| 153 |
-
translate_button = gr.Button("🚀 Translate Now", variant="primary")
|
| 154 |
-
|
| 155 |
-
# Right side - Output
|
| 156 |
-
with gr.Column(scale=1, min_width=400):
|
| 157 |
-
gr.Markdown("### 📘 Output Section")
|
| 158 |
-
status_label = gr.Label(label="Status")
|
| 159 |
-
translation_output = gr.Textbox(
|
| 160 |
-
label="🇫🇷 French Translation",
|
| 161 |
-
placeholder="Your translated text will appear here..."
|
| 162 |
-
)
|
| 163 |
-
pronunciation_output = gr.Textbox(
|
| 164 |
-
label="🔤 Pronunciation (IPA)",
|
| 165 |
-
placeholder="Phonetic pronunciation here..."
|
| 166 |
-
)
|
| 167 |
-
audio_output = gr.Audio(
|
| 168 |
-
label="🔊 Listen to Pronunciation",
|
| 169 |
-
type="filepath"
|
| 170 |
-
)
|
| 171 |
-
file_output = gr.File(label="⬇️ Download Translation Result")
|
| 172 |
-
|
| 173 |
-
# 🔄 Button Click Event
|
| 174 |
-
translate_button.click(
|
| 175 |
-
fn=process_translation,
|
| 176 |
-
inputs=[api_key, english_text],
|
| 177 |
-
outputs=[
|
| 178 |
-
status_label,
|
| 179 |
-
translation_output,
|
| 180 |
-
pronunciation_output,
|
| 181 |
-
file_output,
|
| 182 |
-
audio_output,
|
| 183 |
-
],
|
| 184 |
-
show_progress="full"
|
| 185 |
-
)
|
| 186 |
-
|
| 187 |
-
# 💬 Footer
|
| 188 |
-
gr.Markdown(
|
| 189 |
-
"""
|
| 190 |
-
<hr>
|
| 191 |
-
<div style="text-align:center; color:gray; font-size:14px; padding:10px;">
|
| 192 |
-
Made with ❤️ using <b>Gemini API</b> + <b>Gradio</b> | Designed by <b>Himel</b>
|
| 193 |
-
</div>
|
| 194 |
-
"""
|
| 195 |
-
)
|
| 196 |
-
|
| 197 |
-
app.launch()
|
| 198 |
-
|
| 199 |
app.launch()
|
|
|
|
| 112 |
|
| 113 |
return "Translation Successful!", translated_text, cleaned_pronunciation, result_file_name, audio_path
|
| 114 |
|
| 115 |
+
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
| 116 |
+
gr.Markdown("# English → French Translator with Pronunciation")
|
| 117 |
+
gr.Markdown("Translate English text into **French**, get **pronunciation**, and listen to it!")
|
| 118 |
+
|
| 119 |
+
api_key = gr.Textbox(label="🔑 Gemini API Key", type="password", placeholder="Enter your Gemini API key")
|
| 120 |
+
english_text = gr.Textbox(label="📝 Enter English Text", lines=4, placeholder="Type something in English...")
|
| 121 |
+
|
| 122 |
+
translate_button = gr.Button("Translate to French 🚀") status_label = gr.Label(label="Status")
|
| 123 |
+
|
| 124 |
+
translation_output = gr.Textbox(label="📘 French Translation")
|
| 125 |
+
pronunciation_output = gr.Textbox(label="🔤 Pronunciation (IPA)")
|
| 126 |
+
audio_output = gr.Audio(label="🔊 Listen to Pronunciation", type="filepath")
|
| 127 |
+
file_output = gr.File(label="⬇️ Download Translation Result")
|
| 128 |
+
translate_button.click( fn=process_translation,
|
| 129 |
+
inputs=[api_key, english_text],
|
| 130 |
+
outputs=[status_label, translation_output, pronunciation_output, file_output, audio_output] )
|
| 131 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
app.launch()
|