THEBOGLER commited on
Commit
33ccc01
·
1 Parent(s): 41a0d49

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ import markovify
4
+
5
+ def gen():
6
+ if text in ["1091393561192304661","848565511834566677"]
7
+ size = random.randint(1, 650)
8
+ file_name = "./premium.txt"
9
+ with open(file_name, encoding="utf-8") as f:
10
+ db = f.read()
11
+ db = db.strip().lower()
12
+ text_model = markovify.NewlineText(input_text=db, state_size=1, well_formed=False)
13
+ symbolsplus = [".","~~","!","?"]
14
+ sentence: str = text_model.make_short_sentence(size) or random.choice(
15
+ db.splitlines())[:size] + random.choice(symbolsplus)
16
+ return sentence
17
+ else:
18
+ size = random.randint(1, 128)
19
+ file_name = "./free.txt"
20
+ with open(file_name, encoding="utf-8") as f:
21
+ db = f.read()
22
+ db = db.strip().lower()
23
+ text_model = markovify.NewlineText(input_text=db, state_size=1, well_formed=False)
24
+ symbolsplus = [".","~~","!","?"]
25
+ sentence: str = text_model.make_short_sentence(size) or random.choice(
26
+ db.splitlines())[:size] + random.choice(symbolsplus)
27
+ return sentence
28
+
29
+ iface = gr.Interface(
30
+ fn=gen,
31
+ inputs="text",
32
+ outputs="text",
33
+ examples=[["ID!"], ["Как дела?"]])
34
+ iface.launch()