lm redis bool fix

This commit is contained in:
nckcard
2025-07-03 14:05:04 -07:00
parent 6fee75015b
commit 2b9707cf42
2 changed files with 32 additions and 30 deletions

View File

@@ -450,20 +450,20 @@ def main(args):
# create a nice dict of params to put into redis # create a nice dict of params to put into redis
lm_args = { lm_args = {
'lm_path': lm_path, 'lm_path': lm_path,
'max_active': max_active, 'max_active': int(max_active),
'min_active': min_active, 'min_active': int(min_active),
'beam': beam, 'beam': float(beam),
'lattice_beam': lattice_beam, 'lattice_beam': float(lattice_beam),
'acoustic_scale': acoustic_scale, 'acoustic_scale': float(acoustic_scale),
'ctc_blank_skip_threshold': ctc_blank_skip_threshold, 'ctc_blank_skip_threshold': float(ctc_blank_skip_threshold),
'length_penalty': length_penalty, 'length_penalty': float(length_penalty),
'nbest': nbest, 'nbest': int(nbest),
'blank_penalty': blank_penalty, 'blank_penalty': float(blank_penalty),
'alpha': alpha, 'alpha': float(alpha),
'do_opt': do_opt, 'do_opt': int(do_opt),
'rescore': rescore, 'rescore': int(rescore),
'top_candidates_to_augment': top_candidates_to_augment, 'top_candidates_to_augment': int(top_candidates_to_augment),
'score_penalty_percent': score_penalty_percent, 'score_penalty_percent': float(score_penalty_percent),
} }
# pick GPU # pick GPU
@@ -671,7 +671,6 @@ def main(args):
blank_penalty = float(entry_data.get(b'blank_penalty', blank_penalty)) blank_penalty = float(entry_data.get(b'blank_penalty', blank_penalty))
alpha = float(entry_data.get(b'alpha', alpha)) alpha = float(entry_data.get(b'alpha', alpha))
do_opt = int(entry_data.get(b'do_opt', do_opt)) do_opt = int(entry_data.get(b'do_opt', do_opt))
# opt_cache_dir = entry_data.get(b'opt_cache_dir', opt_cache_dir).decode()
rescore = int(entry_data.get(b'rescore', rescore)) rescore = int(entry_data.get(b'rescore', rescore))
top_candidates_to_augment = int(entry_data.get(b'top_candidates_to_augment', top_candidates_to_augment)) top_candidates_to_augment = int(entry_data.get(b'top_candidates_to_augment', top_candidates_to_augment))
score_penalty_percent = float(entry_data.get(b'score_penalty_percent', score_penalty_percent)) score_penalty_percent = float(entry_data.get(b'score_penalty_percent', score_penalty_percent))
@@ -679,21 +678,20 @@ def main(args):
# make sure that the update remote lm args are put into redis nicely # make sure that the update remote lm args are put into redis nicely
lm_args = { lm_args = {
'lm_path': lm_path, 'lm_path': lm_path,
'max_active': max_active, 'max_active': int(max_active),
'min_active': min_active, 'min_active': int(min_active),
'beam': beam, 'beam': float(beam),
'lattice_beam': lattice_beam, 'lattice_beam': float(lattice_beam),
'acoustic_scale': acoustic_scale, 'acoustic_scale': float(acoustic_scale),
'ctc_blank_skip_threshold': ctc_blank_skip_threshold, 'ctc_blank_skip_threshold': float(ctc_blank_skip_threshold),
'length_penalty': length_penalty, 'length_penalty': float(length_penalty),
'nbest': nbest, 'nbest': int(nbest),
'blank_penalty': blank_penalty, 'blank_penalty': float(blank_penalty),
'alpha': alpha, 'alpha': float(alpha),
'do_opt': do_opt, 'do_opt': int(do_opt),
# 'opt_cache_dir': opt_cache_dir, 'rescore': int(rescore),
'rescore': rescore, 'top_candidates_to_augment': int(top_candidates_to_augment),
'top_candidates_to_augment': top_candidates_to_augment, 'score_penalty_percent': float(score_penalty_percent),
'score_penalty_percent': score_penalty_percent,
} }
r.xadd('remote_lm_args', lm_args) r.xadd('remote_lm_args', lm_args)

View File

@@ -154,10 +154,14 @@ for session, data in test_data.items():
# make sure that the standalone language model is running on the localhost redis ip # make sure that the standalone language model is running on the localhost redis ip
# see README.md for instructions on how to run the language model # see README.md for instructions on how to run the language model
r = redis.Redis(host='localhost', port=6379, db=0) r = redis.Redis(host='localhost', port=6379, db=0)
r.flushall() # clear all streams in redis
# define redis streams for the remote language model
remote_lm_input_stream = 'remote_lm_input' remote_lm_input_stream = 'remote_lm_input'
remote_lm_output_partial_stream = 'remote_lm_output_partial' remote_lm_output_partial_stream = 'remote_lm_output_partial'
remote_lm_output_final_stream = 'remote_lm_output_final' remote_lm_output_final_stream = 'remote_lm_output_final'
# set timestamps for last entries seen in the redis streams
remote_lm_output_partial_lastEntrySeen = get_current_redis_time_ms(r) remote_lm_output_partial_lastEntrySeen = get_current_redis_time_ms(r)
remote_lm_output_final_lastEntrySeen = get_current_redis_time_ms(r) remote_lm_output_final_lastEntrySeen = get_current_redis_time_ms(r)
remote_lm_done_resetting_lastEntrySeen = get_current_redis_time_ms(r) remote_lm_done_resetting_lastEntrySeen = get_current_redis_time_ms(r)