diff --git a/hugvey/story.py b/hugvey/story.py index 0eaca85..97181a6 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -103,6 +103,9 @@ class Message(object): if not 'vol' in msg.params: # prevent clipping on some Lyrebird tracks msg.params['vol'] = .8 + + msg.params['vol'] = float(msg.params['vol']) + return msg def parseForVariables(self): @@ -937,12 +940,23 @@ class Diversion(object): return True +class Configuration(object): + id = 'configuration' + volume = 1 + + @classmethod + def initFromJson(configClass, data, story): + config = Configuration() + config.__dict__.update(data) + return config + storyClasses = { 'Msg': Message, 'Direction': Direction, 'Condition': Condition, 'Diversion': Diversion, + 'Configuration': Configuration, } @@ -1158,6 +1172,8 @@ class Story(object): self.diversions = [el for el in self.elements.values() if type(el) == Diversion] self.interruptionDiversions = [el for el in self.elements.values() if type(el) == Diversion and el.type == 'interrupt'] + configurations = [el for el in self.elements.values() if type(el) == Configuration] + self.configuration = configurations[0] if len(configurations) else Configuration() if currentId: self.currentMessage = self.get(currentId) @@ -1536,13 +1552,16 @@ class Story(object): self.logger.critical(f"error: crash when reading wave file: {fn}") self.logger.exception(e) duration = 10 # some default duration to have something to fall back to - + + params = message.getParams().copy() + params['vol'] = params['vol'] * self.configuration.volume if 'vol' in params else self.configuration.volume + # self.hugvey.google.pause() # pause STT to avoid text events while decision is made self.hugvey.sendCommand({ 'action': 'play', 'file': fn, 'id': message.id, - 'params': message.getParams(), + 'params': params, 'duration': duration }) diff --git a/www/css/styles.css b/www/css/styles.css index 56919f7..e4b258c 100644 --- a/www/css/styles.css +++ b/www/css/styles.css @@ -44,13 +44,14 @@ img.icon { flex-direction: row; height: 100vh; width: 100vw; } - #interface #audioFiles { + #interface #audioFiles, #interface #configuration { position: absolute; - top: 10%; - left: 10%; - right: 10%; - bottom: 10%; - background: #ccc; } + top: 30%; + left: 30%; + right: 30%; + bottom: 30%; + background: #ccc; + overflow: auto; } #status { display: flex; @@ -105,7 +106,7 @@ img.icon { bottom: 3px; right: 3px; } #status .hugvey .light input { - width: 2em; } + width: 3.2em; } #status .hugvey .stats .count { display: inline-block; margin-right: 10px; } diff --git a/www/index.html b/www/index.html index 23c9cf6..bc9d860 100644 --- a/www/index.html +++ b/www/index.html @@ -81,6 +81,7 @@