-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsay
executable file
·191 lines (169 loc) · 5.49 KB
/
say
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
# Phoneme guide:
# http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/SpeechSynthesisProgrammingGuide/Phonemes/Phonemes.html
#
# Regular Expressions guide:
# http://docs.python.org/library/re.html
import sys, re
from subprocess import call
array1 = (
(r'U\.S\.', r' U S '),
(r'@', r' at-sign '),
(r'\s\|\s', r' pipe '),
(r'\s\.\.\s', r' dot dot '),
(r'\s_\s', r' underscore '),
(r'\(\)', r'empty-parentheses'),
(r'\{\}', r'empty-curly-braces'),
(r'\[\]', r'empty-square-brackets'),
(r'<(.{1,20}?)>', r' over \1'),
# (r'\((.{1,20}?)\)', r' of \1'),
(r'\s\?\s', r' question-mark '),
(r'\s=>\s', r' fat-arrow '),
(r'\s->\s', r' arrow '),
(r'\s<\s', r'less-than'),
(r'\s>\s', r'greater-than'),
(r'\s>=\s', r'greater-than-or-equal-to'),
(r'\s<=\s', r'less-than-or-equal-to'),
(r'\^', r'(carat)'),
(r'´', r"'"),
(r'\.\.\.', r'[[slnc 500]]'), # Pause on ellipsis
(r'·', "point"),
(r"$", r'. . .'),
(r'(\d+)\s?[-–—]\s?(\d+)%', r'\1 to \2 percent'),
#(r'\s"(\S)', r' quote, \1'),
#(r'(\S)"\s', r'\1, end quote, '),
(r'“(.{1,50}?)”', r', \1, '),
#(r'“', r'quote,'),
#(r'”', r', end quote, '),
(r'\.$', r'.\n\n'),
(r'(\d)\.(\d)', r'\1 point \2'),
(r'(\D)\.(\w)', r'\1 dot \2'),
(r'(\w)\.(\w)', r'\1 dot \2'),
(r'(\D)\.(\d+)', r'\1. Reference \2.'),
(r'Mt\.', r'mount'),
(r'e\.g\.', r'for example'),
(r'U\.S\.', r'United States'),
(r'\n+', r'[[slnc 200]]'), # Pause on newlines
(r'(\w)-(\w)', r'\1 \2'),
(r'([^:]*)::([^:]*)', r'\1 double-colon \2'),
(r'/', r' slash '),
(r'\[\d+\]', r''), # Remove Wikipedia footnote references [xx]
(r'(\w+?)- (\w+?)', r'\1\2') # Close hyphenated words
)
array2 = (
# General
# ('live', 'lIHv'),
# Occult
# ('Aleister', '1AElEHstr'),
# ('Anubis', '1AEn2AXbIXs'),
# ('Aquino', 'AXkw1IYnOW'),
# ('Crowley', 'kr1OWlIY'),
# ('Enochian', 'AXn1OWkIYAXn'),
# ('grimoire', 'grIHmw1AOr'),
# ('Gurdjieff', 'g1UXrJAXf'),
# ('initiates', 'IHn1IXSIYAXts'),
# ('Ipsissimus', '2IHps1IHsIHmUXs'),
# ('LaVey', 'lAXv1EY'),
# ('LaVeyan', 'lUX +vEYIHn'),
# ('lycanthropy', 'lAYk1AEnTrAXp2IY'),
# ('mage', 'm1EYJ'),
# ('magister', 'm1AEJihstAXr'),
# ('magistry', 'm1AEJihstrIY'),
# ('magus', 'm1EYgAXs'),
# ('Nemo', 'n1IYmOW'),
# ('Satanism', 's1EYtn2IHzm'),
# ('templi', 't1EHmplIY'),
# ('vampirism', 'v1AEmpAXr2IHzAXm'),
# ('Walpurgisnacht', 'wAOlp1AXrgIHsnAOkt'),
# ('Xem', 'k1EHm'),
# ('Xeper', 'k1EHfAXr'),
# ('gods', 'gAAdz'),
# (r'I\s*(°|degree)', 'fUXrst dUXgr1IY'),
# (r'II\s*(°|degree)', 's1EHk2AXndUXgr1IY'),
# (r'III\s*(°|degree)', 'T1IXrdUXgr1IY'),
# (r'IV\s*(°|degree)', 'f1OWrT dUXgr1IY'),
# (r'V\s*(°|degree)', 'f1IHfT dUXgr1IY'),
# (r'VI\s*(°|degree)', 's1IXkT dUXgr1IY'),
# (r'VII\s*(°|degree)', 's1EHvAXnT dUXgr1IY'),
# (r'VIII\s*(°|degree)', '1EYtT dUXgr1IY'),
# (r'IX\s*(°|degree)', 'n1AYnT dUXgr1IY'),
# (r'X\s*(°|degree)', 't1EHnT dUXgr1IY'),
# Philosophy
# ('Nietzsche', 'n1IYCIY'),
# ('praxis', 'prAEksIHs'),
# Politics
# ('anarcho', '2AEn1AArkOW'),
# ('memetic', 'mIYmEHt1IHk'),
# ('memeplexes', 'mIYm1plEHksAXz'),
# ('memeplex', 'mIYm1plEHks'),
# ('meme', 'mIYm'),
# Physiology
# ('androgenic', 'AEndrOWJ1EHnIXk'),
# ('endogenous', 'EHnd1AOJEHnIXs'),
# ('exogenous', 'IXks1AOJEHnIXs'),
# ('periodization', 'pIXrIYUXd2UXz1EYSUXn'),
# ('periodized', 'pIXrIYUXdAYzd'),
# ('periodize', 'pIXrIYUXdAYz'),
# ('progestin', 'prOWJ1EHstIXn'),
# ('reps', '~rEHps'),
# Personal Improvement
# ('Csikszentmihalyi', 'C2IXksEHntm1IYhAY'),
# History
# ('Elizabeth I', 'EHl1IHzAXb2EHT DAX f1UXrst'),
# Miscellaneous
# ('kazillion', 'kUXz1IHlIYUXn'),
# ('snazzy', 'sn1AEzIY'),
# Men's Rights
# ('hypergamy', 'hAYp1IXrgAXmIY'),
# ('hypergamous', 'hAYp1IXrgAXmUXs'),
# Technology
('destructuring', 'de-structuring'),
('tuples', 'tooples'),
('tuple', 'toople'),
('Rustaceans', 'rustaishuns'),
('Rustacean', 'rustaishun'),
('iteration', 'iteraishun'),
('enums', 'eenums'),
('enum', 'eenum'),
('conciseness', 'concise-ness'),
('enumerated', 'enumerayted'),
('iterator', 'itarator'),
('iterators', 'itarators'),
('dyn', 'dine'),
('deref', 'dee-ref'),
('println', 'print-line'),
('rustc', 'rust-c'),
('serde', 'ser-day'),
('TOML', 'Tomal'),
('an SQLite', 'a SQLite'),
('SQLite store', 'sequel light store'),
('SQLite', 'sequel light'),
('async', 'a-sink'),
('uniquing', 'unique-ing'),
('pecs', 'peks'),
('cbor', 'see-bore'),
('dcbor', 'd-see-bore')
)
originalText = ''
for f in sys.stdin:
originalText += f
# Split the text into paragraphs
paragraphs = re.split(r'\s*\n\s*\n\s*', originalText)
# Remove leading and trailing whitespace and join lines for each paragraph
processedParagraphs = [' '.join(p.strip() for p in paragraph.split('\n')) for paragraph in paragraphs]
# Join the paragraphs back together with blank lines in between
originalText = '\n\n'.join(processedParagraphs)
modifiedText = originalText
for t in array1:
pattern = t[0]
replacement = t[1]
modifiedText = re.sub(pattern, replacement, modifiedText, flags = re.IGNORECASE | re.MULTILINE);
for t in array2:
pattern = t[0]
#replacement = ' [[inpt PHON]]' + t[1] + '[[inpt TEXT]] '
replacement = t[1]
pattern = r'\b' + pattern + r'\b'
modifiedText = re.sub(pattern, replacement, modifiedText, flags = re.IGNORECASE | re.MULTILINE);
call(["say", modifiedText])
# print(modifiedText)