Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,16 @@
|
|
1 |
import streamlit as st
|
2 |
from PIL import Image
|
3 |
import google.generativeai as genai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
genai.configure(api_key="AIzaSyBd36RWeqDpLur3E7TTlX3wnyIh_rdhsU8")
|
6 |
|
@@ -69,6 +79,6 @@ if uploaded_file is not None:
|
|
69 |
|
70 |
# Button to print the text from input
|
71 |
if st.button('Print Text'):
|
72 |
-
st.write(response.text)
|
73 |
|
74 |
# Run this with `streamlit run your_script.py`
|
|
|
1 |
import streamlit as st
|
2 |
from PIL import Image
|
3 |
import google.generativeai as genai
|
4 |
+
from googletrans import Translator, LANGUAGES
|
5 |
+
|
6 |
+
def translate_to_persian(text):
|
7 |
+
# Instantiate the Translator object
|
8 |
+
translator = Translator()
|
9 |
+
|
10 |
+
# Translate the text
|
11 |
+
translation = translator.translate(text, src='en', dest='fa')
|
12 |
+
|
13 |
+
return translation.text
|
14 |
|
15 |
genai.configure(api_key="AIzaSyBd36RWeqDpLur3E7TTlX3wnyIh_rdhsU8")
|
16 |
|
|
|
79 |
|
80 |
# Button to print the text from input
|
81 |
if st.button('Print Text'):
|
82 |
+
st.write(translate_to_persian(response.text))
|
83 |
|
84 |
# Run this with `streamlit run your_script.py`
|