Skip to content

Commit

Permalink
porting to python 3.7 for asyncio functions
Browse files Browse the repository at this point in the history
  • Loading branch information
privacyrespected committed Jan 26, 2022
1 parent 2892668 commit d3a4123
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 34 deletions.
Binary file modified __pycache__/UI.cpython-36.pyc
Binary file not shown.
34 changes: 8 additions & 26 deletions alpha_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from chatterbot.trainers import ChatterBotCorpusTrainer
from corpus.customcorpus import * #imports the local corpus
from chatterbot import preprocessors
from modules.bootloader import bootloader
from modules.bootloader import startup1
#this line implements the custom chattebot preprocessors for extra word filter
from preprocessors import clean_words
###############
Expand Down Expand Up @@ -76,28 +76,10 @@ def trainchatbot(trainer): #works in tandem with bootnoise.startupnoise1()
trainer.train(conversation9)


#working path starts here (listed here for checklist)
# 1. check user data
# 2. train NLP data ++ play boot sound 1
# 3. start frontend
# 4. time sleep 1 then start bootmessage
# 5. start the rest of the program


# 2. train NLP data ++ play boot sound 1
try:
Thread(target=trainchatbot(trainer)).start()
Thread(target=playsound("audio/slowtypebeep.mp3")).start()
except Exception as e:
notify("OHNO", e ,90)
print(e)
#boot the system
try:
Thread(target=bootloader()).start()
Thread(target=alpha_frontend()).start()
except Exception as e:
notify("OHNO", e ,90)
print(e)

while True:
speak("HIs")
def alpha_main():
startup1()
while True:
query=listen.lower()
query=str(query)


Binary file modified corpus/__pycache__/customcorpus.cpython-36.pyc
Binary file not shown.
Binary file modified db.sqlite3
Binary file not shown.
2 changes: 2 additions & 0 deletions error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Wed Jan 26 17:23:01 2022
OHNO
Binary file added modules/__pycache__/bootloader.cpython-36.pyc
Binary file not shown.
Binary file added modules/__pycache__/mainsystem.cpython-36.pyc
Binary file not shown.
Binary file added modules/__pycache__/search.cpython-36.pyc
Binary file not shown.
Binary file added modules/__pycache__/sense.cpython-36.pyc
Binary file not shown.
Binary file added modules/__pycache__/weather.cpython-36.pyc
Binary file not shown.
14 changes: 7 additions & 7 deletions modules/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from threading import Thread
from playsound import playsound
import time
from modules.sense import notify
from sense import notify
import random
from modules.sense import speak
from sense import speak
import json
from os import path
import datetime
Expand Down Expand Up @@ -87,8 +87,8 @@ def startup1():
wishMe(user_gender)
elif int(random_functions) == 2:
wishme2(user_name)
def bootloader():
Thread(target=playsound("audio/typingbeep.mp3")).start()
Thread(target=playsound("audio/radar.mp3")).start()
Thread(target=startup1()).start()
def bootload():
if __name__ == "__main__":
Thread(target=startup1()).start
Thread(target=playsound(u"audio/slowtypebeep.mp3")).start()
bootload()
Binary file modified preprocessors/__pycache__/clean_puncuations.cpython-36.pyc
Binary file not shown.
Binary file modified preprocessors/__pycache__/clean_words.cpython-36.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'pprintpp>=0.4.0',
'PyAutoGUI>=0.9.52',
'psutil>=5.7.3',
'playsound>=1.2.2',
'playsound==1.2.2',
"wikipedia",
"PyAudio> =0.2.11",
"spacy>=2.2.2",
Expand Down
22 changes: 22 additions & 0 deletions test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# python3.7+
import asyncio


async def hello():
while True:
print("Hello")
await asyncio.sleep(1)


async def world():
while True:
print("World")
await asyncio.sleep(1)


async def main():
await asyncio.gather(hello(), world())


asyncio.run(main())
Note asyncio.sleep(1) call in each coroutine. It's done to pass the control to the event loop and let another coroutine to be executed.

0 comments on commit d3a4123

Please sign in to comment.