-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
883a9bf
commit 8fd8f27
Showing
7 changed files
with
107 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import speech_recognition as sr | ||
import pyttsx3, random, json | ||
from unicodedata import normalize | ||
from socket import socket, AF_INET, SOCK_STREAM | ||
|
||
def Recognition(): | ||
recognizer = sr.Recognizer() | ||
|
||
with sr.Microphone() as source: | ||
recognizer.adjust_for_ambient_noise(source) | ||
|
||
print('Say:') | ||
|
||
sound = recognizer.listen(source) | ||
speech = recognizer.recognize_google(sound, language='pt').lower() | ||
print('You said: ', speech) | ||
|
||
return ' ' + speech + ' ' | ||
|
||
def speak(text): | ||
speaker = pyttsx3.init('sapi5') | ||
speaker.say(text) | ||
speaker.runAndWait() | ||
|
||
def responseSelector(): | ||
return random.randint(3, 5) | ||
|
||
def languageUnderstanding(phrase): | ||
phraseFilter = [' o ', ' a ', ' os ', ' as ', ' um ', ' uma ', ' uns ', ' umas ', ' ante ', ' apos ', | ||
' ate ', ' com ',' contra ', ' de ' , | ||
' desde ', ' entre ', ' para ', ' perante ', ' por ', ' sem ', ' sob ', ' sobre ', | ||
' como ', ' e ', ' ainda ', ' tambem ', ' contudo ', ' entretanto ', ' mas ', ' entanto ', | ||
' porem ', ' todavia ', ' assim ', ' entao ', ' logo ', ' pois ', ' porque ', ' por ', | ||
' que ', ' para ', ' no ',' na '] | ||
|
||
phraseFiltered = normalize('NFKD', phrase).encode('ASCII', 'ignore').decode('ASCII') | ||
|
||
for word in phraseFilter: | ||
if word in phraseFiltered: | ||
phraseFiltered = phraseFiltered.replace(word, ' ') | ||
|
||
print('Filtered: ', phraseFiltered) | ||
return phraseFiltered | ||
|
||
|
||
class ServerConnection: | ||
def __init__(self): | ||
file = open('E:/Sexta-Feira-Mark_6/Configurations.json', 'r') | ||
configs = json.load(file)['FridayConfigs'] | ||
|
||
self.connection = socket(AF_INET, SOCK_STREAM, 0) | ||
#connection.connect((configs['ServerHost'], configs['Port'] )) | ||
self.connection.connect(('192.168.0.5', 3000 )) | ||
|
||
message = json.dumps({ | ||
'header': 'gazeboindustries09082004', | ||
'request': 'getDevicesJsons' | ||
|
||
}).encode() | ||
|
||
self.connection.send(message) | ||
|
||
self.devicesJson = json.loads(self.connection.recv(1024).decode()) | ||
|
||
def send(self, dict): | ||
message = json.dumps(dict).encode() | ||
|
||
self.connection.send(message) | ||
|
||
return self.connection.recv(1024) | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Functions | ||
|
||
server = Functions.ServerConnection() | ||
|
||
msg = { | ||
'header': 'gazeboindustries09082004', | ||
'request': 'getDevicesJsons' | ||
} | ||
|
||
|
||
#print(server.send(msg)) |
Binary file not shown.