Skip to content

Commit

Permalink
add until-byebye
Browse files Browse the repository at this point in the history
  • Loading branch information
haesleinhuepf committed Aug 18, 2023
1 parent c6a8d90 commit 48ec457
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/bia_bob/_speech_recognition.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
def _listen():
def _listen(until_bye_bye=False):
"""
Activate the microphone and listen to the user.
The passed command is then executed.
If until_bye_bye is True, the discussion is continued until the user says "bye bye".
"""
result = _listen_to_microphone()
if result:
print("You said:", result)

from ._machinery import bob
bob(result)
while True:
result = _listen_to_microphone()
if result:
print("You said:", result)


from ._machinery import bob
bob(result)

if result.lower().strip() in ["bye bye", "bye-bye", "bye", "goodbye", "good bye", "good-bye", "see you later", "see you", "stop", "quit", "halt"]:
return

else:
return

if not until_bye_bye:
return

def _listen_to_microphone():
"""Recognizes speech from microphone and return it as string"""
Expand Down

0 comments on commit 48ec457

Please sign in to comment.