guymorlan commited on
Commit
bb90b8f
·
1 Parent(s): 80ac4dc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ pipeline = pipeline(task="translation", model="guymorlan/DialectTransliterator")
5
+
6
+ st.title("Phonetic transliteration for Palestinian Madani arabic")
7
+
8
+ num_translations = st.sidebar.selectbox("Number of Translations:", [1, 2, 3, 4, 5], index=0)
9
+ input_text = st.text_input("Enter Arabic text:")
10
+
11
+ if input_text:
12
+ result = pipeline(input_text, max_length=1024, num_return_sequences=num_translations, num_beams=max(num_translations, 5))
13
+ st.markdown("<div style='font-size:24px;'>", unsafe_allow_html=True)
14
+ outs = list(set([x["translation_text"] for x in result]))
15
+ for i in range(len(outs)):
16
+ st.markdown(f"{outs[i]}", unsafe_allow_html=True)
17
+ st.markdown("<br>", unsafe_allow_html=True)
18
+ st.markdown("</div>", unsafe_allow_html=True)