File size: 1,988 Bytes
4c0b133
3d3bf92
4c0b133
 
b6c5296
4c0b133
 
b6c5296
4c0b133
 
b6c5296
 
 
 
4c0b133
 
b6c5296
 
 
 
 
4c0b133
 
 
 
 
 
 
b6c5296
 
 
 
 
4c0b133
b6c5296
 
4c0b133
 
 
b6c5296
 
 
4c0b133
b6c5296
 
4c0b133
 
 
b6c5296
 
4c0b133
 
b6c5296
4c0b133
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import streamlit as st
import transformers
from transformers import pipeline

# Load translation pipeline (use your fine-tuned model here later)
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-hi")

# Streamlit page config
st.set_page_config(page_title="Translator", layout="wide")

# Language options
languages = ["English", "Hindi", "Spanish", "Odia", "Telugu"]

# UI starts here
st.markdown("""
    <style>
    .big-font { font-size:25px !important; font-weight: bold; }
    .tab-style { display: flex; gap: 20px; font-size:18px; }
    .tab-style div { cursor: pointer; }
    .output-box { background-color: #f9f9f9; padding: 20px; border-radius: 10px; min-height: 300px; font-size: 22px; }
    .copy-button { margin-top: 10px; }
    </style>
""", unsafe_allow_html=True)

# Create two columns
col1, col2 = st.columns(2)

with col1:
    # Detected Language Dropdown
    source_lang = st.selectbox("Detected Language", languages, index=0)
    
    # Text input
    st.markdown('<div class="big-font">Enter your text:</div>', unsafe_allow_html=True)
    user_input = st.text_area("", "hi how are you", height=250)
    
    # Translate Button
    translate_button = st.button("Translate", use_container_width=True)

with col2:
    # Target Language Dropdown
    target_lang = st.selectbox("Translate To", languages, index=1)
    
    if translate_button and user_input:
        # Right now, not actually changing based on languages selected
        # You can later map different models based on selected languages
        translated_text = translator(user_input, max_length=400)[0]['translation_text']
    else:
        translated_text = ""
    
    # Show translated text
    st.markdown('<div class="output-box">' + (translated_text if translated_text else "") + '</div>', unsafe_allow_html=True)

    # Copy and Paraphrase Buttons
    if translated_text:
        st.button("Copy", use_container_width=True)
        st.button("Paraphrase", use_container_width=True)