Add tempo factor for whole story and log messages with label
This commit is contained in:
parent
a4292a3387
commit
7c7fcf071a
3 changed files with 36 additions and 9 deletions
|
@ -128,7 +128,7 @@ class GoogleVoiceClient(object):
|
||||||
self.logger.log(LOG_BS,"wait for Google Voice")
|
self.logger.log(LOG_BS,"wait for Google Voice")
|
||||||
if not self.isRunning.wait(timeout=1):
|
if not self.isRunning.wait(timeout=1):
|
||||||
continue # re-ceck toBeShutdown
|
continue # re-ceck toBeShutdown
|
||||||
self.logger.debug("Starting Google Voice")
|
self.logger.debug(f"Starting Google Voice for {self.language_code}")
|
||||||
|
|
||||||
|
|
||||||
audio_generator = self.generator()
|
audio_generator = self.generator()
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Utterance(object):
|
||||||
self.lastUpdateTime = startTime
|
self.lastUpdateTime = startTime
|
||||||
|
|
||||||
def setText(self, text, now):
|
def setText(self, text, now):
|
||||||
self.text = text
|
self.text = text.lower() # always lowercase
|
||||||
self.lastUpdateTime = now
|
self.lastUpdateTime = now
|
||||||
|
|
||||||
def hasText(self):
|
def hasText(self):
|
||||||
|
@ -174,6 +174,13 @@ class Message(object):
|
||||||
return self.label
|
return self.label
|
||||||
return self.getText()
|
return self.getText()
|
||||||
|
|
||||||
|
def getTextLabel(self):
|
||||||
|
"""
|
||||||
|
A combination of getText and getLabel for maximum verbosity
|
||||||
|
"""
|
||||||
|
l = f" ({self.label})" if self.label and len(self.label) else ""
|
||||||
|
return f"{self.getText()}{l}"
|
||||||
|
|
||||||
def setReply(self, reply):
|
def setReply(self, reply):
|
||||||
self.reply = reply
|
self.reply = reply
|
||||||
|
|
||||||
|
@ -203,7 +210,7 @@ class Message(object):
|
||||||
return {
|
return {
|
||||||
'id': self.id,
|
'id': self.id,
|
||||||
'time': None if self.reply is None else [u.startTime for u in self.reply.utterances],
|
'time': None if self.reply is None else [u.startTime for u in self.reply.utterances],
|
||||||
'text': self.getText(),
|
'text': self.getTextLabel(),
|
||||||
'replyText': None if self.reply is None else [u.text for u in self.reply.utterances]
|
'replyText': None if self.reply is None else [u.text for u in self.reply.utterances]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +219,8 @@ class Message(object):
|
||||||
return self.audioFile
|
return self.audioFile
|
||||||
|
|
||||||
text = self.getText()
|
text = self.getText()
|
||||||
self.logger.debug(f"Fetching audio for {text}")
|
textlabel = self.getTextLabel()
|
||||||
|
self.logger.debug(f"Fetching audio for {textlabel}")
|
||||||
|
|
||||||
# return "test";
|
# return "test";
|
||||||
async with self.filenameFetchLock:
|
async with self.filenameFetchLock:
|
||||||
|
@ -236,7 +244,7 @@ class Message(object):
|
||||||
|
|
||||||
# print(threading.enumerate())
|
# print(threading.enumerate())
|
||||||
|
|
||||||
self.logger.debug(f"Fetched audio for {text}: {filename}")
|
self.logger.debug(f"Fetched audio for {textlabel}: {filename}")
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
|
@ -1174,6 +1182,7 @@ class Configuration(object):
|
||||||
volume = 1 # Volume multiplier for 'play' command
|
volume = 1 # Volume multiplier for 'play' command
|
||||||
nothing_text = "nothing" # When variable is not set, but used in sentence, replace it with this word.
|
nothing_text = "nothing" # When variable is not set, but used in sentence, replace it with this word.
|
||||||
time_factor = 1
|
time_factor = 1
|
||||||
|
tempo_factor = 1
|
||||||
light0_intensity = 0
|
light0_intensity = 0
|
||||||
light0_fade = 30. # fade duration in seconds
|
light0_fade = 30. # fade duration in seconds
|
||||||
light0_isSophie = False
|
light0_isSophie = False
|
||||||
|
@ -1884,7 +1893,7 @@ class Story(object):
|
||||||
# self.currentReply = self.currentMessage.reply
|
# self.currentReply = self.currentMessage.reply
|
||||||
|
|
||||||
self.logger.info("Current message: ({0}) \"{1}\"".format(
|
self.logger.info("Current message: ({0}) \"{1}\"".format(
|
||||||
message.id, message.getText()))
|
message.id, message.getTextLabel()))
|
||||||
if message.id != self.startMessage.id:
|
if message.id != self.startMessage.id:
|
||||||
self.addToLog(message)
|
self.addToLog(message)
|
||||||
|
|
||||||
|
@ -1905,6 +1914,10 @@ class Story(object):
|
||||||
params = message.getParams().copy()
|
params = message.getParams().copy()
|
||||||
params['vol'] = params['vol'] * self.configuration.volume if 'vol' in params else self.configuration.volume
|
params['vol'] = params['vol'] * self.configuration.volume if 'vol' in params else self.configuration.volume
|
||||||
params['vol'] = "{:.4f}".format(params['vol'])
|
params['vol'] = "{:.4f}".format(params['vol'])
|
||||||
|
params['tempo'] = (float(params['tempo']) if 'tempo' in params else 1) * (float(self.configuration.tempo_factor) if hasattr(self.configuration, 'tempo_factor') else 1)
|
||||||
|
duration = float(duration) / params['tempo']
|
||||||
|
|
||||||
|
params['tempo'] = "{:.4f}".format(params['tempo'])
|
||||||
|
|
||||||
# self.hugvey.google.pause() # pause STT to avoid text events while decision is made
|
# self.hugvey.google.pause() # pause STT to avoid text events while decision is made
|
||||||
self.hugvey.sendCommand({
|
self.hugvey.sendCommand({
|
||||||
|
|
|
@ -1096,7 +1096,7 @@ class Graph {
|
||||||
),
|
),
|
||||||
crel(
|
crel(
|
||||||
'label',
|
'label',
|
||||||
"Timing factor: (< 1 is faster, >1 is slower)",
|
"Condition timing factor: (< 1 is faster, >1 is slower)",
|
||||||
crel('input', {
|
crel('input', {
|
||||||
'type': 'number',
|
'type': 'number',
|
||||||
'on': {
|
'on': {
|
||||||
|
@ -1108,6 +1108,20 @@ class Graph {
|
||||||
'step': 0.01
|
'step': 0.01
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
crel(
|
||||||
|
'label',
|
||||||
|
"Playback tempo factor: (< 1 is faster, >1 is slower)",
|
||||||
|
crel('input', {
|
||||||
|
'type': 'number',
|
||||||
|
'on': {
|
||||||
|
'change': function(e){
|
||||||
|
panopticon.graph.configuration['tempo_factor'] = parseFloat(e.target.value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'value': this.configuration.hasOwnProperty('tempo_factor') ? this.configuration.tempo_factor : 1,
|
||||||
|
'step': 0.01
|
||||||
|
})
|
||||||
|
),
|
||||||
crel('hr'),
|
crel('hr'),
|
||||||
crel('h2', 'Light fade setting #0'),
|
crel('h2', 'Light fade setting #0'),
|
||||||
crel(
|
crel(
|
||||||
|
@ -1577,8 +1591,8 @@ class Graph {
|
||||||
),
|
),
|
||||||
crel( 'label',
|
crel( 'label',
|
||||||
crel( 'span', {
|
crel( 'span', {
|
||||||
"title": "Playback pitch factor"
|
"title": "Playback pitch: negative: lower, positive: higher"
|
||||||
}, 'Pitch factor' ),
|
}, 'Pitch' ),
|
||||||
crel( 'input', {
|
crel( 'input', {
|
||||||
'name': msg['@id'] + '-params.pitch',
|
'name': msg['@id'] + '-params.pitch',
|
||||||
'value': params.hasOwnProperty('pitch') ? params['pitch'] : 0,
|
'value': params.hasOwnProperty('pitch') ? params['pitch'] : 0,
|
||||||
|
|
Loading…
Reference in a new issue