swcrazyfan's picture
Update app.py
27ef783
raw
history blame
No virus
1.31 kB
from happytransformer import HappyTextToText, TTSettings
top_p_sampling_settings = TTSettings(num_beams=25, min_length=0, max_length=512, early_stopping=True)
from happytransformer import HappyTextToText, TTSettings
import gradio as gr
happy_tt = HappyTextToText("T5", "swcrazyfan/Kingify-2Way-T5-Large-v1_1")
ttsettings = TTSettings(num_beams=5, min_length=0, max_length=512, early_stopping=True)
def kingify(text, choice):
if choice == "Kingify":
text = "kingify: " + text
else:
text = "dekingify: " + text
result = happy_tt.generate_text(text, args=ttsettings)
return result.text
iface = gr.Interface(kingify, [gr.inputs.Textbox(lines=5, label="Text to Kingify/Dekingify"), gr.inputs.Radio(["Kingify", "Dekingify"], label="Kingify or Dekingify?")], gr.outputs.Textbox(label="Kingified/Dekingified Text"),description="You can use this to 'translate' to and from 17th-century English. Why is it calle 'Kingify'? I trained the model using the King James Version of the Bible along with a modern translation of the Bible as the dataset. Thus 'Kingify'. For best results, use words or concepts that seem religious--although most things should get a decent result. I've found it's fun to experiment with 17th-century poetry/modern poetry or lyrics.")
iface.launch(inline=False)