File size: 428 Bytes
cc837db
 
 
 
68f8a90
8a45068
 
 
 
5e95957
cc837db
 
 
 
 
 
 
 
 
 
 
929592b
cc837db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
import markovify
import random

dataset = "./dataset.txt"
with open(dataset, encoding="utf-8") as f:
    db = f.read()
db = db.strip().lower()

def gen(text):
  
  text_model = markovify.NewlineText(
    input_text=db, 
    state_size=1, 
    well_formed=False
  )

  sentence = text_model.make_short_sentence(50)

  return sentence

iface = gr.Interface(fn=gen, inputs="text", outputs="text")
iface.launch()