Pitch modifier for story configuration

This commit is contained in:
Ruben van de Ven 2020-01-13 08:23:30 +01:00
parent 7c7fcf071a
commit ac11645dd0
2 changed files with 112 additions and 92 deletions

View file

@ -25,8 +25,10 @@ from .communication import LOG_BS
mainLogger = logging.getLogger("hugvey")
logger = mainLogger.getChild("narrative")
class Utterance(object):
"""Part of a reply"""
def __init__(self, startTime):
self.startTime = startTime
self.endTime = None
@ -1151,7 +1153,6 @@ class Diversion(object):
async def _returnAfterTimeout(self, story):
story.logger.info(f"Finalise diversion: {self.id}")
async def _divergeIfInterrupted(self, story, msgFrom, msgTo, direction):
"""
This is here as a placeholder for the interruption diversion.
@ -1177,12 +1178,14 @@ class Diversion(object):
return True
class Configuration(object):
id = 'configuration'
volume = 1 # Volume multiplier for 'play' command
nothing_text = "nothing" # When variable is not set, but used in sentence, replace it with this word.
time_factor = 1
tempo_factor = 1
time_factor = 1 # time is multiplied to timeouts etc. (not playback)
tempo_factor = 1 # tempo is multiplied (playback)
pitch_modifier = 1 # pitch is added (playback)
light0_intensity = 0
light0_fade = 30. # fade duration in seconds
light0_isSophie = False
@ -1916,9 +1919,12 @@ class Story(object):
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'])
params['pitch'] = (float(params['pitch']) if 'pitch' in params else 0)\
+ (float(self.configuration.pitch_modifier) if hasattr(self.configuration, 'pitch_modifier') else 0)
params['pitch'] = "{:.4f}".format(params['pitch'])
# self.hugvey.google.pause() # pause STT to avoid text events while decision is made
self.hugvey.sendCommand({
'action': 'play',

View file

@ -1122,6 +1122,20 @@ class Graph {
'step': 0.01
})
),
crel(
'label',
"Playback pitch modifier: (< 0 is lower, >0 is higher)",
crel('input', {
'type': 'number',
'on': {
'change': function(e){
panopticon.graph.configuration['pitch_modifier'] = parseFloat(e.target.value)
}
},
'value': this.configuration.hasOwnProperty('pitch_modifier') ? this.configuration.pitch_modifier : 0,
'step': 1
})
),
crel('hr'),
crel('h2', 'Light fade setting #0'),
crel(