swcrazyfan commited on
Commit
891fc93
1 Parent(s): 10ccd06

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from happytransformer import HappyTextToText, TTSettings
2
+ top_p_sampling_settings = TTSettings(num_beams=25, min_length=0, max_length=512, early_stopping=True)
3
+ from happytransformer import HappyTextToText, TTSettings
4
+ import gradio as gr
5
+ happy_tt = HappyTextToText("T5", "swcrazyfan/Kingify-2Way-T5-Large-v1_1")
6
+ ttsettings = TTSettings(num_beams=25, min_length=0, max_length=512, early_stopping=True)
7
+
8
+ def kingify(text, choice):
9
+ if choice == "Kingify":
10
+ text = "kingify: " + text
11
+ else:
12
+ text = "dekingify: " + text
13
+ result = happy_tt.generate_text(text, args=ttsettings)
14
+ return result.text
15
+
16
+ iface = gr.Interface(kingify, [gr.inputs.Textbox(lines=5, label="Text to Kingify"), gr.inputs.Radio(["Kingify", "Dekingify"], label="Kingify or Dekingify?")], gr.outputs.Textbox(label="Kingified Text"))
17
+ iface.launch(inline=False)