Skip to content

Commit

Permalink
Merge pull request #15 from haesleinhuepf/continuous-discussion
Browse files Browse the repository at this point in the history
Continuous discussion
  • Loading branch information
haesleinhuepf committed Aug 18, 2023
2 parents ca9fbcd + 810be40 commit 90f02c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 78 deletions.
77 changes: 5 additions & 72 deletions demo/speech_recognition.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "63fd4ae0-0709-4ee1-8bf4-b09d5752dc3d",
"metadata": {
"tags": []
Expand Down Expand Up @@ -142,67 +142,7 @@
"output_type": "stream",
"text": [
"Listening...\n",
"You said: segment the image again using an algorithm for segmenting images write membranes\n"
]
},
{
"data": {
"text/markdown": [
"The image has been segmented using an algorithm for segmenting images with membranes, and the result is shown as segmented_image.jpg."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Listening...\n",
"You said: it meant the image using the seed watershed algorithm\n"
]
},
{
"data": {
"text/markdown": [
"The image has been segmented using the Local-Minima-Seeded-Watershed algorithm, which is suitable for segmenting images with membranes. The result is shown as segmented_image.jpg."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Listening...\n",
"You said: show doesn't mentation reserved\n"
]
},
{
"data": {
"text/markdown": [
"Apologies for the confusion. The segmentation result is not available for display at the moment."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Listening...\n",
"You said: show the segmented image\n"
"You said: segment the image again using the seed watershed algorithm\n"
]
},
{
Expand Down Expand Up @@ -242,7 +182,7 @@
{
"data": {
"text/markdown": [
"The segmented image has been displayed."
"The image has been segmented using the seed watershed algorithm and the result is shown as segmented_image.jpg."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand Down Expand Up @@ -276,27 +216,20 @@
"output_type": "stream",
"text": [
"Listening...\n",
"You said: thank you bye-bye bye-bye\n"
"You said: bye-bye\n"
]
},
{
"data": {
"text/markdown": [
"You're welcome! Goodbye!"
"Goodbye! Have a great day!"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Listening...\n"
]
}
],
"source": [
Expand Down
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 90f02c1

Please sign in to comment.