|
|
|
|
@ -478,6 +478,61 @@ def build_config(_config_file):
|
|
|
|
|
|
|
|
|
|
return CONFIG
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reload_voice_config(CONFIG, config_file):
|
|
|
|
|
_voice_cfg_dir = os.path.dirname(os.path.abspath(config_file))
|
|
|
|
|
_voice_cfg_file = os.path.join(_voice_cfg_dir, 'voice.cfg')
|
|
|
|
|
|
|
|
|
|
if not os.path.isfile(_voice_cfg_file):
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
voice_config = configparser.ConfigParser()
|
|
|
|
|
try:
|
|
|
|
|
voice_config.read(_voice_cfg_file)
|
|
|
|
|
except Exception:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
_voice_section = 'VOICE'
|
|
|
|
|
_has_voice = voice_config.has_section(_voice_section)
|
|
|
|
|
if not _has_voice:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
_voice_keys = {}
|
|
|
|
|
|
|
|
|
|
for _ann_num in range(1, 5):
|
|
|
|
|
_prefix = 'ANNOUNCEMENT' if _ann_num == 1 else 'ANNOUNCEMENT{}'.format(_ann_num)
|
|
|
|
|
_voice_keys['{}_ENABLED'.format(_prefix)] = voice_config.getboolean(_voice_section, '{}_ENABLED'.format(_prefix), fallback=False)
|
|
|
|
|
_voice_keys['{}_FILE'.format(_prefix)] = voice_config.get(_voice_section, '{}_FILE'.format(_prefix), fallback='locucion')
|
|
|
|
|
_voice_keys['{}_TG'.format(_prefix)] = voice_config.getint(_voice_section, '{}_TG'.format(_prefix), fallback=9)
|
|
|
|
|
_voice_keys['{}_TIMESLOT'.format(_prefix)] = voice_config.getint(_voice_section, '{}_TIMESLOT'.format(_prefix), fallback=2)
|
|
|
|
|
_voice_keys['{}_MODE'.format(_prefix)] = voice_config.get(_voice_section, '{}_MODE'.format(_prefix), fallback='hourly')
|
|
|
|
|
_voice_keys['{}_INTERVAL'.format(_prefix)] = voice_config.getint(_voice_section, '{}_INTERVAL'.format(_prefix), fallback=3600)
|
|
|
|
|
_voice_keys['{}_LANGUAGE'.format(_prefix)] = voice_config.get(_voice_section, '{}_LANGUAGE'.format(_prefix), fallback='es_ES')
|
|
|
|
|
|
|
|
|
|
_voice_keys['RECORDING_ENABLED'] = voice_config.getboolean(_voice_section, 'RECORDING_ENABLED', fallback=False)
|
|
|
|
|
_voice_keys['RECORDING_TG'] = voice_config.getint(_voice_section, 'RECORDING_TG', fallback=9)
|
|
|
|
|
_voice_keys['RECORDING_TIMESLOT'] = voice_config.getint(_voice_section, 'RECORDING_TIMESLOT', fallback=2)
|
|
|
|
|
_voice_keys['RECORDING_FILE'] = voice_config.get(_voice_section, 'RECORDING_FILE', fallback='grabacion')
|
|
|
|
|
_voice_keys['RECORDING_LANGUAGE'] = voice_config.get(_voice_section, 'RECORDING_LANGUAGE', fallback='es_ES')
|
|
|
|
|
|
|
|
|
|
_voice_keys['TTS_VOCODER_CMD'] = voice_config.get(_voice_section, 'TTS_VOCODER_CMD', fallback='')
|
|
|
|
|
_voice_keys['TTS_AMBESERVER_HOST'] = voice_config.get(_voice_section, 'TTS_AMBESERVER_HOST', fallback='')
|
|
|
|
|
_voice_keys['TTS_AMBESERVER_PORT'] = voice_config.getint(_voice_section, 'TTS_AMBESERVER_PORT', fallback=2460)
|
|
|
|
|
|
|
|
|
|
for _tts_num in range(1, 5):
|
|
|
|
|
_prefix = 'TTS_ANNOUNCEMENT{}'.format(_tts_num)
|
|
|
|
|
_voice_keys['{}_ENABLED'.format(_prefix)] = voice_config.getboolean(_voice_section, '{}_ENABLED'.format(_prefix), fallback=False)
|
|
|
|
|
_voice_keys['{}_FILE'.format(_prefix)] = voice_config.get(_voice_section, '{}_FILE'.format(_prefix), fallback='texto{}'.format(_tts_num))
|
|
|
|
|
_voice_keys['{}_TG'.format(_prefix)] = voice_config.getint(_voice_section, '{}_TG'.format(_prefix), fallback=9)
|
|
|
|
|
_voice_keys['{}_TIMESLOT'.format(_prefix)] = voice_config.getint(_voice_section, '{}_TIMESLOT'.format(_prefix), fallback=2)
|
|
|
|
|
_voice_keys['{}_MODE'.format(_prefix)] = voice_config.get(_voice_section, '{}_MODE'.format(_prefix), fallback='hourly')
|
|
|
|
|
_voice_keys['{}_INTERVAL'.format(_prefix)] = voice_config.getint(_voice_section, '{}_INTERVAL'.format(_prefix), fallback=3600)
|
|
|
|
|
_voice_keys['{}_LANGUAGE'.format(_prefix)] = voice_config.get(_voice_section, '{}_LANGUAGE'.format(_prefix), fallback='es_ES')
|
|
|
|
|
|
|
|
|
|
CONFIG['GLOBAL'].update(_voice_keys)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Used to run this file direclty and print the config,
|
|
|
|
|
# which might be useful for debugging
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|