Spaces:
Runtime error
Runtime error
File size: 631 Bytes
4a378c3 32eadcf 4a378c3 32eadcf 4a378c3 32eadcf 4a378c3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
import random
import markovify
def gen(text):
text = text.lower()
file_name = "./dataset.txt"
with open(file_name, "a", encoding="utf-8") as f:
f.write(f"{text}\n")
with open(file_name, encoding="utf-8") as f:
db = f.read()
db = db.strip().lower()
text_model = markovify.NewlineText(input_text=db, state_size=1, well_formed=False)
symbolsplus = [".","~~","!","?"]
sentence: str = text_model.make_short_sentence(100) or random.choice(
db.splitlines())[:100] + random.choice(symbolsplus)
return sentence
iface = gr.Interface(fn=gen, inputs="text", outputs="text")
iface.launch() |