red / app.py
code128code's picture
Update app.py
7605136 verified
raw
history blame contribute delete
769 Bytes
import gradio as gr
import markovify
with open('trond.txt') as f:
trondcorpus = f.read()
text_model = markovify.NewlineText(trondcorpus, state_size=3)
#trondmodel_file = open('trond.pkl', 'wb')
#text_model = text_model.compile('trond.pkl')
#here we define a model unloader, so we can unload models after each use
#def unload_model(model):
# del model
# unload_model(text_model)
#with open ("trond.pkl", "rb") as f:
# loaded_trond = pickle.load(f)
# await ctx.send(loaded_trond.make_sentence(tries=100))
# unload_model(loaded_trond)
def redtalk(text):
# return "Hello " + name + "!!"
text = text_model.make_sentence(tries=100)
return text
iface = gr.Interface(fn=redtalk, inputs="text", outputs="text")
iface.launch()