Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +11 -0
src/streamlit_app.py
CHANGED
@@ -108,6 +108,17 @@ if img_file_buffer is not None:
|
|
108 |
st.markdown("### 📷 Captured Image")
|
109 |
st.image(img_file_buffer, caption="Uploaded via camera", use_column_width=True)
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
# --- Footer ---
|
112 |
st.markdown("""
|
113 |
---
|
|
|
108 |
st.markdown("### 📷 Captured Image")
|
109 |
st.image(img_file_buffer, caption="Uploaded via camera", use_column_width=True)
|
110 |
|
111 |
+
def translate_text(text, target_lang):
|
112 |
+
try:
|
113 |
+
url = f"https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl={target_lang}&dt=t&q={requests.utils.quote(text)}"
|
114 |
+
response = requests.get(url)
|
115 |
+
if response.status_code == 200:
|
116 |
+
return response.json()[0][0][0]
|
117 |
+
except:
|
118 |
+
return text
|
119 |
+
return text
|
120 |
+
|
121 |
+
|
122 |
# --- Footer ---
|
123 |
st.markdown("""
|
124 |
---
|