Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,36 @@
|
|
1 |
import streamlit as st
|
2 |
from happytransformer import HappyTextToText, TTSettings
|
3 |
|
4 |
-
|
|
|
5 |
args = TTSettings(num_beams=5, min_length=1)
|
6 |
|
7 |
-
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from happytransformer import HappyTextToText, TTSettings
|
3 |
|
4 |
+
checkpoint = "team-writing-assistant/t5-base-c4jfleg"
|
5 |
+
happy_tt = HappyTextToText("T5", checkpoint)
|
6 |
args = TTSettings(num_beams=5, min_length=1)
|
7 |
|
8 |
+
st.title("Check & Improve English Grammar")
|
9 |
+
st.markdown("This writing assistant detects π and corrects βοΈ grammatical mistakes for you!")
|
10 |
|
11 |
+
st.subheader("Example text: ")
|
12 |
+
col1, col2 = st.columns([1,1])
|
13 |
+
with col1:
|
14 |
+
example_1 = st.button("Speed of light is fastest then speed of sound")
|
15 |
+
with col2:
|
16 |
+
example_2 = st.button("Who are the president?")
|
17 |
+
|
18 |
+
input_text = st.text_area('Enter your text here')
|
19 |
+
button = st.button('Submit')
|
20 |
+
|
21 |
+
def output(input_text):
|
22 |
+
with st.spinner('Detecting π..'):
|
23 |
+
input_text = "grammar: " + input_text
|
24 |
+
result = happy_tt.generate_text(input_text, args=args)
|
25 |
+
st.markdown("## " + result.text)
|
26 |
+
|
27 |
+
if example_1:
|
28 |
+
output("Speed of light is fastest then speed of sound")
|
29 |
+
if example_2:
|
30 |
+
output("Who are the president?")
|
31 |
+
if input_text:
|
32 |
+
output(input_text)
|
33 |
+
|
34 |
+
st.subheader("")
|
35 |
+
|
36 |
+
st.text("Built by Team Writing Assistant β€οΈ")
|