Update app.py
Browse files
app.py
CHANGED
@@ -15,13 +15,13 @@ def main():
|
|
15 |
|
16 |
col1, col2 = st.columns([1, 1])
|
17 |
with col1:
|
18 |
-
st.markdown("<div style='margin-bottom: 10px;'></div>", unsafe_allow_html=True)
|
19 |
input_type = st.radio("Input", ["Text", "File Upload"], horizontal=True, label_visibility="collapsed", key="input_type")
|
20 |
user_text = st.text_area("Enter or paste text", height=200, key="text_input").strip() if input_type == "Text" else ""
|
21 |
if input_type == "File Upload":
|
22 |
doc_file = st.file_uploader("Upload TXT File", type=["txt"], key="doc_input", accept_multiple_files=False, label_visibility="collapsed")
|
23 |
user_text = doc_file.read().decode("utf-8").strip() if doc_file else ""
|
24 |
-
|
25 |
if user_text:
|
26 |
start_time = time.time()
|
27 |
detected_options = lang_detect.detect_language(user_text) if len(user_text) >= 10 else [("English", 1.0, "English")]
|
@@ -53,7 +53,7 @@ def main():
|
|
53 |
st.warning(f"Translation error: {str(e)}. Using input as fallback.")
|
54 |
|
55 |
with col2:
|
56 |
-
st.markdown("<div style='margin-bottom: 10px;'></div>", unsafe_allow_html=True)
|
57 |
if "translated_text" in st.session_state and st.session_state.translated_text:
|
58 |
st.text_area("Translation:", value=st.session_state.translated_text, height=200, key="output_area")
|
59 |
st.write(f"Translation time: {st.session_state.translation_time:.2f} seconds")
|
|
|
15 |
|
16 |
col1, col2 = st.columns([1, 1])
|
17 |
with col1:
|
18 |
+
st.markdown("<div style='margin-bottom: 10px;'></div>", unsafe_allow_html=True)
|
19 |
input_type = st.radio("Input", ["Text", "File Upload"], horizontal=True, label_visibility="collapsed", key="input_type")
|
20 |
user_text = st.text_area("Enter or paste text", height=200, key="text_input").strip() if input_type == "Text" else ""
|
21 |
if input_type == "File Upload":
|
22 |
doc_file = st.file_uploader("Upload TXT File", type=["txt"], key="doc_input", accept_multiple_files=False, label_visibility="collapsed")
|
23 |
user_text = doc_file.read().decode("utf-8").strip() if doc_file else ""
|
24 |
+
|
25 |
if user_text:
|
26 |
start_time = time.time()
|
27 |
detected_options = lang_detect.detect_language(user_text) if len(user_text) >= 10 else [("English", 1.0, "English")]
|
|
|
53 |
st.warning(f"Translation error: {str(e)}. Using input as fallback.")
|
54 |
|
55 |
with col2:
|
56 |
+
st.markdown("<div style='margin-bottom: 10px;'></div>", unsafe_allow_html=True)
|
57 |
if "translated_text" in st.session_state and st.session_state.translated_text:
|
58 |
st.text_area("Translation:", value=st.session_state.translated_text, height=200, key="output_area")
|
59 |
st.write(f"Translation time: {st.session_state.translation_time:.2f} seconds")
|