Skip to content

Commit

Permalink
Adapt
Browse files Browse the repository at this point in the history
  • Loading branch information
haiwei-luo committed Jun 24, 2024
1 parent 182b72a commit b612ed9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ def main(args: dict) -> None:
output_dir = args["output_dir"]

r = sr.Recognizer()
with sr.Microphone(device_index=mic_index) as source:
with sr.Microphone(device_index=13,sample_rate=16000) as source:
print("Say something!")
audio = r.listen(source)
audio = r.listen(source, timeout=5, phrase_time_limit=5)
print("Finished listening")

with open(os.path.join(output_dir, "microphone.raw"), "wb") as f:
f.write(audio.get_raw_data())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def check_name(self, ud):
detection.name == ud.guest_data[self.guest_name_in]["name"]
and detection.confidence > ud.confidence
):
rospy.loginfo(f"Detection {detection.name} has confidence {detection.confidence} > {ud.confidence}")
return "succeeded"
else:
rospy.loginfo(f"Detection {detection.name} has confidence {detection.confidence} <= {ud.confidence}")
return "failed"

def __init__(
Expand Down
13 changes: 10 additions & 3 deletions tasks/receptionist/src/receptionist/states/introduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def stringify_guest_data(guest_data: Dict[str, Any], guest_id: str) -> str:
relevant_guest_data.setdefault(
"attributes",
{
"has_hair": True,
"hair_shape": "unknown",
"hair_colour": "unknown",
"facial_hair": "No_Beard",
Expand All @@ -47,19 +48,20 @@ def stringify_guest_data(guest_data: Dict[str, Any], guest_id: str) -> str:
print(relevant_guest_data["attributes"].items())

for attribute, value in relevant_guest_data["attributes"].items():
if value != "unknown" and value != False:
if value != "unknown" and value != False and value != "No_Beard":
known_attributes[attribute] = value
print("These are the known attributes")
print(known_attributes)

has_hair = False
detection = False # Whenever the an attribute is detected in the for loop, the detection flag is set to true
# so that multiple attributes are not checked at the same time

for attribute, value in known_attributes.items():
if attribute == "has_hair":
has_hair = True
break
if has_hair == False:
guest_str += "They are bald."


ignored_attributes = [
"top",
Expand All @@ -85,6 +87,8 @@ def stringify_guest_data(guest_data: Dict[str, Any], guest_id: str) -> str:
ignored_attributes.append("has_hair")

for attribute, value in known_attributes.items():
detection = False # Whenever the an attribute is detected in the for loop, the detection flag is set to true
# so that multiple attributes are not checked at the same time
if attribute in ignored_attributes:
detection = True
if has_hair:
Expand All @@ -98,6 +102,9 @@ def stringify_guest_data(guest_data: Dict[str, Any], guest_id: str) -> str:
f"They have {relevant_guest_data['attributes'][attribute]} hair."
)
detection = True
else:
if attribute == "hair_shape" or attribute == "hair_colour":
detection = True
if attribute == "facial_hair":
guest_str += f"They have facial hair."
detection = True
Expand Down

0 comments on commit b612ed9

Please sign in to comment.