TensorSpeech / TensorFlowASR

:zap: TensorFlowASR: Almost State-of-the-art Automatic Speech Recognition in Tensorflow 2. Supported languages that can use characters or subwords
https://huylenguyen.com/asr
Apache License 2.0
917 stars 242 forks source link

RNN-Transducer TFlite conversion Broken #247

Open SupreethRao99 opened 2 years ago

SupreethRao99 commented 2 years ago

Hello,

Im trying to convert a pertained model trained on librispeech, but I run into the following error

tensorflow.lite.python.convert_phase.ConverterError: input resource[0] expected type resource != float, the type of streaming_transducer_greedy_while_streaming_transducer_decoder_streaming_transducer_prediction_embedding_embedding_lookup_11394_0[0]
        In {{node streaming_transducer_greedy/while/streaming_transducer_decoder/streaming_transducer_prediction_embedding/embedding_lookup}}
        Failed to functionalize Control Flow V1 ops. Consider using Control Flow V2 ops instead. See https://www.tensorflow.org/api_docs/python/tf/compat/v1/enable_control_flow_v2.

to run the tflite conversion, I ran the below code

python3 examples/rnn_transducer/tflite.py --saved Librispeech/25.h5 --subwords output rnnt.tflite

Platform OS : MacOS 10.15.7 Python : 3.9 Tensorflow-cpu : 2.6.3

Could you suggest a possible way to convert a model to tflite as installing tf-nightly causes dependency issues and does not allow any code to be run at all.

Thank You!

liuyibox commented 1 year ago

Any updated solution here? I encountered the same issue here with tf2.9.

liuyibox commented 1 year ago

This bug has been resolved https://github.com/tensorflow/tensorflow/issues/42410#issuecomment-1201150119. Basically, we just need to load model while are are loading the concrete function, i.e., change this line to converter = tf.lite.TFLiteConverter.from_concrete_functions([concrete_func], model).