1
0
mirror of https://github.com/MarkParker5/STARK.git synced 2025-11-28 21:39:53 +02:00

Create main loop (main.py), background threads, config.py

This commit is contained in:
dQz6tMwk8rJqvDR
2020-07-19 22:27:01 +03:00
parent 1f40468622
commit 97083de0fa
6 changed files with 116 additions and 14 deletions

40
main.py Normal file
View File

@@ -0,0 +1,40 @@
import SpeechRecognition
import Text2Speech
import SmallTalk
from Command import Command
listener = SpeechRecognition.SpeechToText()
voice = Text2Speech.Engine()
threads = []
memory = []
listener.listen_noise()
def check_threads():
for thread in threads:
if thread['finish_event'].is_set():
responce = thread['thread'].join()
if responce['text']:
voice.generate(responce['text']).speak()
thread['finish_event'].clear()
del thread
while True: # main loop
check_threads()
print('Listening...')
speech = listener.listen()
text = speech['text']
print('You: ')
if text:
cmd = Command.find(text)
responce = cmd.start(text)
memory.insert(0, {
'text': text,
'cmd': cmd,
'responce': responce
})
if responce['type'] == 'background': # add background thread to list
threads.append(responce['thread'])
if responce['text']:
voice.generate(responce['text']).speak()
else:
print(speech['status'])