From d8d9d1b72b80f805d61ab7431b2aed9199926a6d Mon Sep 17 00:00:00 2001 From: Loy van Beek Date: Sat, 7 May 2022 14:47:09 +0200 Subject: [PATCH] Apply black --- src/hmi_picovoice/server.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/hmi_picovoice/server.py b/src/hmi_picovoice/server.py index 702f4b0..ead6648 100644 --- a/src/hmi_picovoice/server.py +++ b/src/hmi_picovoice/server.py @@ -12,25 +12,33 @@ class Server(AbstractHMIServer): - def __init__(self, name: str, context_url: str, require_endpoint: bool, rate: float): + def __init__( + self, name: str, context_url: str, require_endpoint: bool, rate: float + ): super(Server, self).__init__(name) self._context_url = context_url self._require_endpoint = require_endpoint self._rate = rate - self._intent_client = actionlib.SimpleActionClient("get_intent", GetIntentAction) + self._intent_client = actionlib.SimpleActionClient( + "get_intent", GetIntentAction + ) rospy.loginfo(f"Waiting for {self._intent_client.action_client.ns} ..") self._intent_client.wait_for_server() - rospy.loginfo(f"Server initialized (context_url={context_url}, require_endpoint={require_endpoint})") + rospy.loginfo( + f"Server initialized (context_url={context_url}, require_endpoint={require_endpoint})" + ) def _determine_answer(self, description, grammar, target, is_preempt_requested): - self._intent_client.send_goal(GetIntentGoal( - context_url=self._context_url, - require_endpoint=self._require_endpoint, - intents=[grammar] - )) + self._intent_client.send_goal( + GetIntentGoal( + context_url=self._context_url, + require_endpoint=self._require_endpoint, + intents=[grammar], + ) + ) r = rospy.Rate(self._rate) while not rospy.is_shutdown(): @@ -41,9 +49,13 @@ def _determine_answer(self, description, grammar, target, is_preempt_requested): result = self._intent_client.get_result() if result is not None: - return HMIResult( - semantics={kv.key: kv.value for kv in result.slots}, - sentence=result.intent - ) if result.is_understood else None + return ( + HMIResult( + semantics={kv.key: kv.value for kv in result.slots}, + sentence=result.intent, + ) + if result.is_understood + else None + ) r.sleep()