-
Notifications
You must be signed in to change notification settings - Fork 0
/
PyAudio2Talkie.py
654 lines (557 loc) · 25.7 KB
/
PyAudio2Talkie.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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
import sys
import os
import re
import binascii
import time
from threading import Thread
from PyQt5.QtCore import QFile, QFileInfo, QSettings, Qt, QTextStream, QTimer, QThread, QRegExp, QElapsedTimer,QEvent, pyqtSignal
from PyQt5.QtWidgets import QStyleFactory,QSizePolicy, QMainWindow, QTextEdit, QAction, QApplication, QMessageBox, QFileDialog, QDialog, QCheckBox, QLabel, QComboBox,QGroupBox,QHBoxLayout, QGridLayout,QFormLayout,QVBoxLayout,QDialogButtonBox, QSplashScreen
from PyQt5.QtGui import QIcon, QPixmap, QFont, QColor, QTextCharFormat, QSyntaxHighlighter
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrintDialog
import webbrowser
try:
import configparser
except:
from six.moves import configparser
from shutil import copyfile
def str2bool(v):
return str(v).lower() in ("yes", "true", "t", "1")
class ConvertAudio(QThread):
sec_signal = pyqtSignal(str)
def __init__(self, parent=None, audio_file='', wav_file='', syntax='0', wrap= True, is_bin= False):
super(ConvertAudio, self).__init__(parent)
self.current_time = 0
self.wrap = wrap
self.is_bin = is_bin
self.syntax = syntax
self.audio_file = audio_file
self.wav_file = wav_file[:-4]
self.newline_bit = 16
self.is_version3 = False
if (sys.version_info > (3, 0)):
# Python 3 code in this block
self.is_version3 = True
if self.is_bin == True:
self.newline_bit = 8
def __del__(self):
self.wait()
def get_output(self, code):
if self.syntax =='0':
return "#include <Talkie.h>\n\nTalkie voice;\n\nconst uint8_t sp%s[] PROGMEM = {\n%s\n};\n\nvoid setup(){\n voice.say(sp%s);\n}\nvoid loop(){\n}\n" % ( self.wav_file,code, self.wav_file)
elif self.syntax=='1':
return "const uint8_t sp%s[] PROGMEM = {\n%s\n};" % (self.wav_file,code)
else:
return code
def run(self):
# this is a special fxn that's called with the start() fxn
if os.path.isfile(self.audio_file):
# start of code variable declaration based from audio filename
code = ''
try:
# display code to text area
with open(self.audio_file, "rb") as f:
index = 1
while True:
byte = f.read(1)
if not byte:
break
if self.is_bin == False:
# Python version affects bytes conversion
# in python3 we must decode converted byte to avoid exception
if self.is_version3:
#print ("%s0x%s," % ( code,(binascii.hexlify(byte)).decode("ascii").upper()))
code = ("%s0x%s, " % (code, (binascii.hexlify(byte)).decode("ascii").strip().upper()))
else:
#print ("%s0x%s," % (code,(binascii.hexlify(byte))))
code = ("%s0x%s, " % (code, (binascii.hexlify(byte)).strip().upper()))
else:
bint = ord(byte) #get byte integer value
code = ("%s%s, " % (code, "{0:08b}".format(bint))) #convert int value to bits binary
if self.wrap == True:
if index >= self.newline_bit:
code = code +"\n"
index =0
index = index+1
time.sleep(1)
self.sec_signal.emit(code) # display code to text area
except Exception as ex:
self.sec_signal.emit(str(ex)) # display code to text area
print("Exception: %s" % ex)
finally:
f.close()
code = code[:-1]
final_code = self.get_output( code )
#print(final_code)
self.sec_signal.emit(final_code) # display code to text area
pass
class Highlighter(QSyntaxHighlighter):
def __init__(self, parent=None):
super(Highlighter, self).__init__(parent)
keywordFormat = QTextCharFormat()
keywordFormat.setForeground(QColor(0, 151, 156))
#keywordFormat.setForeground(Qt.darkBlue)
keywordFormat.setFontWeight(QFont.Bold)
keywordPatterns = ["\\bchar\\b", "\\bclass\\b", "\\bconst\\b",
"\\bdouble\\b", "\\benum\\b", "\\bexplicit\\b", "\\bfriend\\b",
"\\binline\\b", "\\bint\\b", "\\blong\\b", "\\bnamespace\\b",
"\\boperator\\b", "\\bprivate\\b", "\\bprotected\\b",
"\\bpublic\\b", "\\bshort\\b", "\\bsignals\\b", "\\bsigned\\b",
"\\bslots\\b", "\\bstatic\\b", "\\bstruct\\b",
"\\btemplate\\b", "\\btypedef\\b", "\\btypename\\b",
"\\bunion\\b", "\\bunsigned\\b", "\\bvirtual\\b", "\\bvoid\\b",
"\\bvolatile\\b", "\\bPROGMEM\\b"]
self.highlightingRules = [(QRegExp(pattern), keywordFormat)
for pattern in keywordPatterns]
classFormat = QTextCharFormat()
classFormat.setFontWeight(QFont.Bold)
classFormat.setForeground(Qt.darkMagenta)
self.highlightingRules.append((QRegExp("\\bQ[A-Za-z]+\\b"),
classFormat))
singleLineCommentFormat = QTextCharFormat()
singleLineCommentFormat.setForeground(Qt.red)
self.highlightingRules.append((QRegExp("//[^\n]*"),
singleLineCommentFormat))
self.multiLineCommentFormat = QTextCharFormat()
self.multiLineCommentFormat.setForeground(Qt.red)
quotationFormat = QTextCharFormat()
quotationFormat.setForeground(Qt.darkGreen)
self.highlightingRules.append((QRegExp("\".*\""), quotationFormat))
notesFormat = QTextCharFormat()
notesFormat.setForeground(Qt.red)
self.highlightingRules.append((QRegExp("^Note.+"), notesFormat))
labelFormat = QTextCharFormat()
labelFormat.setForeground(Qt.blue)
self.highlightingRules.append((QRegExp(r"\w+: "), labelFormat))
datatypeFormat = QTextCharFormat()
datatypeFormat.setForeground(Qt.darkGreen)
self.highlightingRules.append((QRegExp("uint8_t"), datatypeFormat))
talkieFormat = QTextCharFormat()
talkieFormat.setForeground(QColor(233, 115, 0))
self.highlightingRules.append((QRegExp("Talkie"), talkieFormat))
includeFormat = QTextCharFormat()
includeFormat.setForeground(QColor(94, 109, 3))
self.highlightingRules.append((QRegExp("^#include"), includeFormat))
functionFormat = QTextCharFormat()
functionFormat.setFontItalic(True)
functionFormat.setForeground(Qt.blue)
self.highlightingRules.append((QRegExp("\\b[A-Za-z0-9_]+(?=\\()"),
functionFormat))
self.commentStartExpression = QRegExp("/\\*")
self.commentEndExpression = QRegExp("\\*/")
def highlightBlock(self, text):
for pattern, format in self.highlightingRules:
expression = QRegExp(pattern)
index = expression.indexIn(text)
while index >= 0:
length = expression.matchedLength()
self.setFormat(index, length, format)
index = expression.indexIn(text, index + length)
self.setCurrentBlockState(0)
startIndex = 0
if self.previousBlockState() != 1:
startIndex = self.commentStartExpression.indexIn(text)
while startIndex >= 0:
endIndex = self.commentEndExpression.indexIn(text, startIndex)
if endIndex == -1:
self.setCurrentBlockState(1)
commentLength = len(text) - startIndex
else:
commentLength = endIndex - startIndex + self.commentEndExpression.matchedLength()
self.setFormat(startIndex, commentLength,
self.multiLineCommentFormat)
startIndex = self.commentStartExpression.indexIn(text,
startIndex + commentLength)
class OptionDialog(QDialog):
NumGridRows = 3
NumButtons = 4
def __init__(self, parent=None):
super(OptionDialog, self).__init__(parent)
self.init_variables()
self.createThemesGroupBox()
self.createGridGroupBox()
self.createFormGroupBox()
buttonBox = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
buttonBox.accepted.connect(self.accept)
buttonBox.rejected.connect(self.reject)
mainLayout = QVBoxLayout()
mainLayout.addWidget(self.horizontalGroupBox)
mainLayout.addWidget(self.formGroupBox)
mainLayout.addWidget(self.gridGroupBox)
mainLayout.addWidget(buttonBox)
self.setLayout(mainLayout)
#self.changeStyle('Windows')
self.setWindowTitle("Options")
self.setWindowIcon(QIcon('images/convert.png'))
self.selectionchange(self.output)
def init_variables(self):
self.output_formats = ["Arduino Syntax -Full","Arduino Syntax -Declaration","Plain Bytes"]
self.config_global = configparser.ConfigParser()
self.dir_name = os.path.dirname(os.path.realpath(__file__))
self.opts_preview = os.path.join(self.dir_name, "configs","preview")
self.global_file = os.path.join(self.dir_name, "configs/global.ini")
self.config_global.read(self.global_file)
self.output= self.config_global.get('global', 'output')
self.theme = self.config_global.get('global', 'theme')
self.wrap = self.config_global.get('global', 'wrap')
self.is_bin = self.config_global.get('global', 'binary')
def createThemesGroupBox(self):
self.horizontalGroupBox = QGroupBox("Themes")
self.horizontalGroupBox.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed)#disabled auto stretching
layout = QHBoxLayout()
self.originalPalette = QApplication.palette()
styleComboBox = QComboBox()
styleComboBox.addItems(QStyleFactory.keys())
styleComboBox.setCurrentIndex(styleComboBox.findText(self.theme))
styleComboBox.activated[str].connect(self.changeStyle)
styleLabel = QLabel("&Style:")
styleLabel.setBuddy(styleComboBox)
layout.addWidget(styleLabel)
layout.addWidget(styleComboBox)
self.horizontalGroupBox.setLayout(layout)
def createGridGroupBox(self):
self.gridGroupBox = QGroupBox("Ouput Preview")
layout = QGridLayout()
font = QFont()
font.setFamily('Courier')
font.setFixedPitch(True)
font.setPointSize(8)
self.smallEditor = QTextEdit()
self.smallEditor.setPlainText("Tarsier Preview")
self.smallEditor.setReadOnly(True)
self.smallEditor.setFont(font)
self.highlighter = Highlighter(self.smallEditor.document())
layout.addWidget(self.smallEditor, 0, 2, 4, 1)
#layout.setColumnStretch(1, 10)
#layout.setColumnStretch(2, 20)
self.gridGroupBox.setLayout(layout)
def createFormGroupBox(self):
self.formGroupBox = QGroupBox("Output")
self.formGroupBox.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed) #disabled auto stretching
layout = QFormLayout()
self.cb = QComboBox()
for f in self.output_formats:
self.cb.addItem(f)
self.cb.currentIndexChanged.connect(self.selectionchange)
self.cb.setCurrentIndex(int(self.output))
layout.addRow(QLabel("Formatting: "), self.cb)
self.checkboxWrap = QCheckBox("Newline created every 16 byte in converted output. ")
self.checkboxWrap.setChecked(str2bool(self.wrap))
self.checkboxWrap.toggled.connect(self.check_changed)
layout.addRow(QLabel("Wrapping"), self.checkboxWrap)
self.checkboxBinary = QCheckBox("Check if you want Binary output type in byte conversion otherwise default Hex.")
self.checkboxBinary.setChecked(str2bool(self.is_bin))
self.checkboxBinary.toggled.connect(self.check_changed)
layout.addRow(QLabel("Type"), self.checkboxBinary)
self.formGroupBox.setLayout(layout)
def selectionchange(self,i):
self.output =str(i)
self.opts_file = os.path.join(self.opts_preview, ("%s.txt" %i))
if os.path.isfile(self.opts_file):
f = open(self.opts_file, 'r')
with f:
data = f.read()
self.smallEditor.setText(data)
self.save_config()
def check_changed(self):
self.wrap = str(self.checkboxWrap.isChecked())
self.is_bin = str(self.checkboxBinary.isChecked())
self.save_config()
def changeStyle(self, styleName):
self.theme = styleName
print (self.theme)
self.save_config()
QApplication.setStyle(QStyleFactory.create(self.theme))
QApplication.setPalette(self.originalPalette)
def save_config(self):
self.config_global.set('global', 'theme', self.theme)
self.config_global.set('global', 'output', self.output)
self.config_global.set('global', 'wrap', self.wrap)
self.config_global.set('global', 'binary', self.is_bin)
# Writing our configuration file
with open(self.global_file, 'w') as configfile:
self.config_global.write(configfile)
pass
class PyTalkieWindow(QMainWindow):
def __init__(self):
super().__init__()
self.copiedtext = ""
self.init_vars()
self.init_config()
self.init_vars()
self.init_editor()
self.init_ui()
def init_config(self):
self.config_opts = configparser.ConfigParser()
self.config_global = configparser.ConfigParser()
self.config_menus = configparser.ConfigParser()
self.config_tools = configparser.ConfigParser()
self.dir_name = os.path.dirname(os.path.realpath(__file__))
self.opts_file = os.path.join(self.dir_name, "configs/options.ini")
self.menu_file = os.path.join(self.dir_name, "configs/menus.ini")
self.tool_file = os.path.join(self.dir_name, "configs/toolbars.ini")
self.global_file = os.path.join(self.dir_name, "configs/global.ini")
def save_config(self):
self.config_global.set('global', 'width', str(
self.frameGeometry().width()))
self.config_global.set('global', 'height', str(
self.frameGeometry().height()))
self.config_global.set('global', 'init_dir', self.lastOpenedFolder)
self.config_global.set('global', 'wav_source', self.new_wavFilename)
self.config_global.set('global', 'wav_file', self.source_wavFilename)
#self.config_global.set('global', 'geometry', str(self.screenGeometry()))
# Writing our configuration file
with open(self.global_file, 'w') as configfile:
self.config_global.write(configfile)
pass
def reinit_configs(self):
self.config_global.read(self.global_file)
self.lastOpenedFolder = self.config_global.get('global', 'init_dir')
self.source_wavFilename = self.config_global.get('global', 'wav_source')
self.new_wavFilename = self.config_global.get('global', 'wav_file')
self.width = self.config_global.get('global', 'width')
self.height = self.config_global.get('global', 'height')
self.geometry = self.config_global.get('global', 'geometry')
self.theme = self.config_global.get('global', 'theme')
self.syntax = self.config_global.get('global', 'output')
self.wrap = self.config_global.get('global', 'wrap')
self.is_bin = self.config_global.get('global', 'binary')
self.open_file(self.source_wavFilename)
def init_vars(self):
self.is_loading = False
self.lastOpenedFolder = "C:\\"
self.source_wavFilename = ''
self.new_wavFilename = ''
self.wavFile = ''
self.geometry = ''
self.theme = ''
self.syntax = ''
self.wrap = True
def init_editor(self):
font = QFont()
font.setFamily('Courier')
font.setFixedPitch(True)
font.setPointSize(8)
self.textEdit = QTextEdit()
self.setCentralWidget(self.textEdit)
self.textEdit.setFont(font)
self.highlighter = Highlighter(self.textEdit.document())
def init_ui(self):
self.menus = {}
self.config_menus.read(self.menu_file)
menubar = self.menuBar()
for section in self.config_menus.sections():
topMenu = menubar.addMenu(section)
for option in self.config_menus.options(section):
menuLabel = self.config_menus.get(section, option)
self.menus[option] = QAction(
QIcon('images/%s.png' % option), menuLabel, self)
# self.menus[option].setShortcut('Ctrl+Q')
self.menus[option].setStatusTip(menuLabel)
self.menus[option].triggered.connect(
lambda checked, tag=option: self.do_clickEvent(checked, tag))
topMenu.addAction(self.menus[option])
self.toolbars = {}
self.config_tools.read(self.tool_file)
for section in self.config_tools.sections():
topToolbar = self.addToolBar(section)
for option in self.config_tools.options(section):
toolLabel = self.config_tools.get(section, option)
self.toolbars[option] = QAction(
QIcon('images/%s.png' % option), toolLabel, self)
# self.menus[option].setShortcut('Ctrl+Q')
self.toolbars[option].setStatusTip(toolLabel)
self.toolbars[option].triggered.connect(
lambda checked, tag=option: self.do_clickEvent(checked, tag))
topToolbar.addAction(self.toolbars[option])
self.reinit_configs()
self.statusBar()
self.setGeometry(200, 200, int(self.width), int(self.height))
self.setWindowTitle('PyAudio-Talkie Synthesis')
self.setWindowIcon(QIcon('images/convert.png'))
QApplication.setStyle(QStyleFactory.create(self.theme))
self.set_details(self.new_wavFilename)
self.show()
pass
def get_audioName(self, filename):
trim_name = re.sub(' +', ' ', filename)
trim_name = trim_name.replace(' ', '_')
return trim_name.replace('-', '').upper()
def do_clickEvent(self, checked, tag):
if self.is_loading == True:
return
if tag == 'open':
self.openo()
pass
elif tag == 'convert':
self.start_convert()
pass
elif tag == 'save':
self.save()
pass
elif tag == 'option':
self.option_dialog()
pass
elif tag=='copy':
self.copy()
pass
elif tag == 'about':
self.about()
pass
elif tag == 'print':
self.print()
pass
elif tag == 'preview':
self.print_preview()
pass
elif tag == 'exit':
self.close()
pass
elif tag == 'qt':
QApplication.instance().aboutQt()
pass
else:
print(tag)
pass
def closeEvent(self, event):
self.save_config()
reply = QMessageBox.question(self, 'Exit',
"Are you sure to quit?", QMessageBox.Yes |
QMessageBox.No, QMessageBox.No)
if reply == QMessageBox.Yes:
self.statusBar().showMessage('Quiting...')
event.accept()
else:
event.ignore()
#self.save()
#event.accept()
def start_convert(self):
if os.path.isfile(self.new_wavFilename):
# change the cursor
QApplication.setOverrideCursor(Qt.WaitCursor)
self.is_loading = True
self._converter = ConvertAudio(
audio_file=self.new_wavFilename, wav_file=self.wavFile, syntax=self.syntax, wrap= str2bool(self.wrap), is_bin=str2bool(self.is_bin))
self._converter.sec_signal.connect(self.textEdit.setText)
self._converter.start()
self._converter.wait()
QApplication.restoreOverrideCursor()
self.is_loading = False
def convert_completed(self):
if self.thread.is_alive():
self.statusBar().showMessage("Converting %s" % self.new_wavFilename)
else:
QApplication.restoreOverrideCursor()
self.is_loading = False
self.statusBar().showMessage('Ready...')
def openo(self):
self.statusBar().showMessage('Open Audio (WAV) files')
fname = QFileDialog.getOpenFileName(
self, 'Open Audio File', self.lastOpenedFolder, "WAV files (*.wav);;All files (*.*)")
if fname[0]:
self.open_file(fname[0])
def open_file(self, fullfilename):
if fullfilename:
folder, filename = os.path.split(fullfilename)
self.lastOpenedFolder = folder
self.new_wavFilename = os.path.join(
os.getcwd(), 'sounds', filename)
self.wavFile = self.get_audioName(filename)
self.statusBar().showMessage(self.new_wavFilename)
try:
copyfile(fullfilename, self.new_wavFilename)
except:
pass
self.set_details(fullfilename)
def set_details(self, full_filename):
if os.path.isfile(full_filename):
folder, filename = os.path.split(full_filename)
file_details = "[Source Details]\n Size: %s\n Filename: %s\n NewFilename: %s\n Directory: %s\n FullPath: %s\n WrapOutput: %s\n" % (os.path.getsize(full_filename),filename, self.wavFile, folder,full_filename,self.wrap)
file_details += "\nClick Convert to generate Talkie speech compatible data for Arduino...\n\nNote: the bigger file size of audio file, the longer it takes to execute conversion."
self.textEdit.setText(file_details)
def save(self):
data = self.textEdit.toPlainText()
if data.strip():
self.statusBar().showMessage('Add extension to file name')
fname = QFileDialog.getSaveFileName(self, 'Save File', self.lastOpenedFolder,"All Files (*);;Text Files (*.txt);;Arduino Sketch (*.ino)")
if fname and os.path.isfile(fname[0]):
try:
file = open(fname[0], 'w')
file.write(data)
file.close()
except:
pass
def copy(self):
self.copiedtext = self.textEdit.toPlainText()
clipboard = QApplication.clipboard()
clipboard.setText(self.copiedtext , mode=clipboard.Clipboard)
event = QEvent(QEvent.Clipboard)
QApplication.sendEvent(clipboard, event)
def option_dialog(self):
opt_dialog = OptionDialog(self)
opt_dialog.setWindowModality(Qt.ApplicationModal)
opt_dialog.resize(500,500)
opt_dialog.exec_()
self.reinit_configs()
def print(self):
try:
dialog = QPrintDialog()
if dialog.exec_() == QDialog.Accepted:
self.textEdit.document().print_(dialog.printer())
except:
pass
def print_preview(self):
try:
dialog = QPrintPreviewDialog()
dialog.setWindowIcon(QIcon('images/convert.png'))
dialog.paintRequested.connect(self.textEdit.print_)
dialog.exec_()
except:
pass
def about(self):
QMessageBox.about(self, "About PyAudio-Talkie Synthesis",
"<b>PyAudio-Talkie Synthesis</b><br>"
"Version: <b>1.1.8101.99616</b><br><br>"
"Copyright © <b> Tarsier 2018</b><br><br>"
"GUI based ( of <b>ArduinoTalkieSpeech-Py</b>) that convert audio <br>"
"file (WAV) to <b>Talkie</b> (speech synthesis for arduino) <br>"
"compatible data.")
if __name__ == '__main__':
app = QApplication(sys.argv)
'''
#Dark Fusion Theme
app.setStyle('Fusion')
palette = QPalette()
palette.setColor(QPalette.Window, QColor(53,53,53))
palette.setColor(QPalette.WindowText, Qt.white)
palette.setColor(QPalette.Base, QColor(15,15,15))
palette.setColor(QPalette.AlternateBase, QColor(53,53,53))
palette.setColor(QPalette.ToolTipBase, Qt.white)
palette.setColor(QPalette.ToolTipText, Qt.white)
palette.setColor(QPalette.Text, Qt.white)
palette.setColor(QPalette.Button, QColor(53,53,53))
palette.setColor(QPalette.ButtonText, Qt.white)
palette.setColor(QPalette.BrightText, Qt.red)
palette.setColor(QPalette.Highlight, QColor(142,45,197).lighter())
palette.setColor(QPalette.HighlightedText, Qt.black)
app.setPalette(palette)
'''
# create splashscreen, use the pic in folder img/bee2.jpg
splash_pix = QPixmap('images/splash.png')
splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
# set the splash window flag, keep the window stay on tophint and frameless
splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
splash.setEnabled(False)
#splash.setMask(splash_pix.mask())
# show the splashscreen
splash.show()
# create elapse timer to cal time
timer = QElapsedTimer()
timer.start()
# we give 3 secs
while timer.elapsed() < 3000 :
app.processEvents()
pywin = PyTalkieWindow()
# call finish method to destory the splashscreen
splash.finish(pywin)
sys.exit(app.exec_())