@@ -106,8 +106,9 @@ def __init__(self):
106
106
self .subscription = self .create_subscription (
107
107
HeadsetAudioData , self ._audio_topic , self .listener_callback , 1
108
108
)
109
- self ._publisher = self .create_publisher (DialogueUtterance ,
110
- self ._utterances_topic , 1 )
109
+ self ._publisher = self .create_publisher (
110
+ DialogueUtterance , self ._utterances_topic , 1
111
+ )
111
112
112
113
self .audio_stream = []
113
114
self .t = threading .Thread ()
@@ -204,18 +205,15 @@ def asr_server_request_thread(self, audio_data, num_channels, sample_rate):
204
205
if response :
205
206
response_text = json .loads (response .text )["text" ]
206
207
self .log .info ("Complete ASR text is:\n " + f'"{ response_text } "' )
207
- self ._publish_response (response_text ,
208
- self ._is_sentence_tokenize_mode )
208
+ self ._publish_response (response_text , self ._is_sentence_tokenize_mode )
209
209
210
210
def _publish_response (self , response_text : str , tokenize_sentences : bool ):
211
211
if tokenize_sentences :
212
212
for sentence in sent_tokenize (response_text ):
213
- self ._publisher .publish (
214
- self ._construct_dialogue_utterance (sentence ))
213
+ self ._publisher .publish (self ._construct_dialogue_utterance (sentence ))
215
214
else :
216
- self ._publisher .publish (
217
- self ._construct_dialogue_utterance (response_text ))
218
-
215
+ self ._publisher .publish (self ._construct_dialogue_utterance (response_text ))
216
+
219
217
def _construct_dialogue_utterance (self , msg_text : str ) -> DialogueUtterance :
220
218
msg = DialogueUtterance ()
221
219
msg .header .frame_id = "ASR"
@@ -225,7 +223,6 @@ def _construct_dialogue_utterance(self, msg_text: str) -> DialogueUtterance:
225
223
return msg
226
224
227
225
228
-
229
226
main = make_default_main (ASR )
230
227
231
228
0 commit comments