-
Notifications
You must be signed in to change notification settings - Fork 0
/
stt.py
146 lines (118 loc) · 4.57 KB
/
stt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import pickle
import pyttsx3
import time
engine = pyttsx3.init() # инициализация движка
# зададим свойства
engine.setProperty('rate', 200) # скорость речи
engine.setProperty('volume', 1) # громкость (0-1)
try:
with open("data0.pickle", "rb") as f:
data = pickle.load(f)
except Exception as ex:
print("Error during unpickling object (Possibly unsupported):", ex)
import random as r
fill = open("res.txt", "w+")
while 1:
print("режим: список - 1, прогрессия - 2")
mode = int(input())
if mode == 1:
stri = ""
print("длина:")
i = int(input())
print("лимит:")
limit = int(input())
print("разброс:")
viiiu = int(input())
d = r.randint(0, len(data)-1)
nexxt = data[d][r.randint(1, len(data[d])-1)]
stri += nexxt
count = 0
while count < i:
t = 1
while t != 0:
t = 0
for j in data:
if j[0] == nexxt:
nexxt = j[r.randint(1, len(j)-1)]
stri += " " + nexxt
t += 1
if t == 0:
stri += ". "
if len(stri) > limit and len(stri) < limit + viiiu:
print(str(count + 1) + ". " + stri)
fill.write(str(count + 1) + ". " + stri + "\n")
## engine.say(stri) # запись фразы в очередь
## engine.runAndWait()
count += 1
stri = ""
d = r.randint(0, len(data)-1)
nexxt = data[d][r.randint(1, len(data[d])-1)]
stri += nexxt
fill.close()
engine.say("всё закончилось. давай пиши ещё.") # запись фразы в очередь
engine.runAndWait()
elif mode == 2:
stri = ""
print("длина:")
i = int(input())
print("старт:")
limit = int(input())
print("шаг:")
shag = int(input())
d = r.randint(0, len(data)-1)
nexxt = data[d][r.randint(1, len(data[d])-1)]
stri += nexxt
count = 0
while count < i:
t = 1
while t != 0:
t = 0
for j in data:
if j[0] == nexxt:
nexxt = j[r.randint(1, len(j)-1)]
stri += " " + nexxt
t += 1
if t == 0:
stri += ". "
if len(stri) > limit:
print(str(count + 1) + ". " + stri + " ___ " + str(len(stri)))
## engine.say(stri)
## engine.runAndWait()
count += 1
limit += shag
if len(stri) > limit:
limit = len(stri)
stri = ""
d = r.randint(0, len(data)-1)
nexxt = data[d][r.randint(1, len(data[d])-1)]
stri += nexxt
elif mode == 3:
stri = ""
nexxt = data[0][1]
stri += nexxt
print(nexxt)
cn = 0
count = 0
while cn < len(data):
nexxt = data[cn][1]
stri += nexxt
t = 0
for j in data:
if j[0] == nexxt:
nexxt = j[1]
stri += " " + nexxt
t += 1
## break
if t == 0:
stri += ". "
print(str(count + 1) + ". " + stri)
fill.write(str(count + 1) + ". " + stri + "\n")
## engine.say(stri) # запись фразы в очередь
## engine.runAndWait()
count += 1
stri = ""
cn+=1
fill.close()
engine.say("всё закончилось. давай пиши ещё.") # запись фразы в очередь
engine.runAndWait()
print("")