From bf3c9cc962ad29bd744636dfc62c9c94cc93a05f Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Thu, 14 Nov 2019 20:23:59 +0100 Subject: [PATCH] Disable pre-fetching of sentences with variables --- hugvey/story.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hugvey/story.py b/hugvey/story.py index 7ac1964..07a753b 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -143,11 +143,12 @@ class Message(object): self.variableValues[name] = value self.logger.warn(f"Set variable, fetch {name}") - if not None in self.variableValues.values(): - self.logger.warn(f"now fetch {name} for {self.id}") - asyncio.get_event_loop().create_task(self.getAudioFilePath()) -# asyncio.get_event_loop().call_soon_threadsafe(self.getAudioFilePath) -# self.logger.warn(f"started {name}") + # disable prefetching of audio files, to avoid a bunch of calls at once to the voice api's + # Other possiblity would be to wrap getAudioFilePath() into a method that delays execution incrementally + # with an asyncio.sleep(i) +# if not None in self.variableValues.values(): +# self.logger.warn(f"now fetch {name} for {self.id}") +# asyncio.get_event_loop().create_task(self.getAudioFilePath()) def getVariableValue(self, var): return self.variableValues[var] if (self.variableValues[var] is not None) else self.story.configuration.nothing_text #TODO: translate nothing to each language