From dfa4509ab4b6db471ca73dad5b750dc4e681b8d6 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Tue, 23 Jan 2018 15:32:59 -0200 Subject: [PATCH] Move decoder module initialization to initialize_globals As of TF 1.5, you can't access tf.app.flags before `tf.app.run` is called. --- DeepSpeech.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/DeepSpeech.py b/DeepSpeech.py index 83f30687..c2a22621 100755 --- a/DeepSpeech.py +++ b/DeepSpeech.py @@ -325,6 +325,14 @@ def initialize_globals(): log_error('Path specified in --one_shot_infer is not a valid file.') exit(1) + if not os.path.exists(os.path.abspath(FLAGS.decoder_library_path)): + print('ERROR: The decoder library file does not exist. Make sure you have ' \ + 'downloaded or built the native client binaries and pass the ' \ + 'appropriate path to the binaries in the --decoder_library_path parameter.') + + global custom_op_module + custom_op_module = tf.load_op_library(FLAGS.decoder_library_path) + # Logging functions # ================= @@ -478,13 +486,6 @@ def BiRNN(batch_x, seq_length, dropout): # Output shape: [n_steps, batch_size, n_hidden_6] return layer_6 -if not os.path.exists(os.path.abspath(FLAGS.decoder_library_path)): - print('ERROR: The decoder library file does not exist. Make sure you have ' \ - 'downloaded or built the native client binaries and pass the ' \ - 'appropriate path to the binaries in the --decoder_library_path parameter.') - -custom_op_module = tf.load_op_library(FLAGS.decoder_library_path) - def decode_with_lm(inputs, sequence_length, beam_width=100, top_paths=1, merge_repeated=True): decoded_ixs, decoded_vals, decoded_shapes, log_probabilities = (