Skip to content
Snippets Groups Projects
Commit 7dfe6a66 authored by Timo Birr's avatar Timo Birr :rage:
Browse files

Merge branch 'master' into feature/asynchronous-skills

parents 43174910 dc3a810f
No related branches found
No related tags found
No related merge requests found
Pipeline #21307 passed
......@@ -11,6 +11,7 @@ from armarx_memory.segments.TextToSpeech import TextToSpeechWriter
from armarx_speech.stop_hook import StopHook
import Ice
class MemoryStopListener:
"""
......@@ -64,8 +65,20 @@ class MemoryStopListener:
def fetch_updates(self, updated_ids: ty.List["MemoryID"]):
updated_ids = [updated_id for updated_id in updated_ids if "/text/" in str(updated_id)]
snapshots_dict = self.stt_reader.reader.query_snapshots(updated_ids)
updated_ids = [updated_id for updated_id in updated_ids if updated_id.entity_name == "text"]
try:
snapshots_dict = self.stt_reader.reader.query_snapshots(updated_ids)
except Ice.ConnectionRefusedException as e:
self.log.warning("Reconnecting SpeechToTextReader ...")
self.stt_reader = SpeechToTextReader.from_mns(self.mns)
try:
snapshots_dict = self.stt_reader.reader.query_snapshots(updated_ids)
self.log.info("SpeechToTextReader is OK.")
except Ice.ConnectionRefusedException as e:
# Give up
self.log.warning("Failed to reconnect SpeechToTextReader.")
return
for snapshot in snapshots_dict.values():
data = SpeechToText.from_aron_ice(snapshot.instances[0].data)
for command in self.STOP_COMMANDS:
......@@ -75,10 +88,22 @@ class MemoryStopListener:
break
def say_stop(self):
self.tts_writer.commit(
entity_id=self.tts_writer.make_entity_name(self.name),
text="stopping",
)
try:
self.tts_writer.commit(
entity_id=self.tts_writer.make_entity_name(self.name),
text="stopping",
)
except Ice.ConnectionRefusedException as e:
self.mns = MemoryNameSystem.wait_for_mns(logger=self.log)
self.tts_writer = TextToSpeechWriter.from_mns(self.mns)
try:
self.tts_writer.commit(
entity_id=self.tts_writer.make_entity_name(self.name),
text="stopping",
)
except Ice.ConnectionRefusedException as e:
self.log.warning("Failed to reconnect SpeechToTextReader.")
return
def send_stop(self):
t_total_start = time.time()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment