Disable pre-fetching of sentences with variables

This commit is contained in:
Ruben van de Ven 2019-11-14 20:23:59 +01:00
parent de82f73363
commit bf3c9cc962

View file

@ -143,11 +143,12 @@ class Message(object):
self.variableValues[name] = value self.variableValues[name] = value
self.logger.warn(f"Set variable, fetch {name}") self.logger.warn(f"Set variable, fetch {name}")
if not None in self.variableValues.values(): # disable prefetching of audio files, to avoid a bunch of calls at once to the voice api's
self.logger.warn(f"now fetch {name} for {self.id}") # Other possiblity would be to wrap getAudioFilePath() into a method that delays execution incrementally
asyncio.get_event_loop().create_task(self.getAudioFilePath()) # with an asyncio.sleep(i)
# asyncio.get_event_loop().call_soon_threadsafe(self.getAudioFilePath) # if not None in self.variableValues.values():
# self.logger.warn(f"started {name}") # self.logger.warn(f"now fetch {name} for {self.id}")
# asyncio.get_event_loop().create_task(self.getAudioFilePath())
def getVariableValue(self, var): 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 return self.variableValues[var] if (self.variableValues[var] is not None) else self.story.configuration.nothing_text #TODO: translate nothing to each language