Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speech recognition #19

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Speech recognition #19

wants to merge 9 commits into from

Conversation

rita-gama
Copy link
Collaborator

No description provided.

@RiscadoA
Copy link
Member

Is this ready to review?

@rita-gama
Copy link
Collaborator Author

Is this ready to review?

Yes!

Comment on lines +45 to +51
with ZipFile("../data/vosk-model-small-en-us-0.15.zip", 'r') as zObject:

# Extracting the zip
zObject.extractall(path="../data")

# Delete the zip file
os.remove("../data/vosk-model-small-en-us-0.15.zip")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to generalize this and move it inside the for above it.
Check if the file extension is .zip, in which case you extract it and delete the .zip file.

Comment on lines +54 to +63
def install_packages():
"""Install the required python libraries."""

for package in PACKAGES:
print("Downloading python library {}...".format(package))
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", package], stdout=subprocess.DEVNULL)
except Exception as e:
print("Failed to download library {}".format(package))
print("Exception {}".format(e))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing python packages is not so straight forward on my distro, I would prefer us adding a requirements.txt with the necessary packages and just install them with pip.

Comment on lines +19 to +20
def emotionFromPhrase(self):
# TODO: implement this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be within nlp.py?

def __init__(self, phrase) -> None:
self.phrase = phrase

def setPhrase(self, phrase):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename to set?

self.phrase = phrase

def setPhrase(self, phrase):
self.phrase = self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.phrase = self
self.phrase = phrase

def setPhrase(self, phrase):
self.phrase = self

def getPhrase(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename to get?

Comment on lines +34 to +42
while True:
try:
data = self.stream.read(4096)
if self.recognizer.AcceptWaveform(data):
res = json.loads(self.recognizer.Result())
phrase = res["text"]
print(phrase)
except KeyboardInterrupt:
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas on how to integrate it with the rest of the code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants