CoolFace
Modelpublic

DocWolle/whisper_tflite_models

sourceHugging Facemitupdated 6mo agoView on Hugging Face
12likes17kdownloads
Model Card

Whisper tflite models for use in Whisper app on F-Droid

"transcribe-translate" models provide signatures for "servingtranscribe" and "servingtranslate" to force the model to perform a certain action

@tf.function( inputsignature=[ tf.TensorSpec((1, 80, 3000), tf.float32, name="inputfeatures"), ], ) def transcribe(self, inputfeatures): outputs = self.model.generate( inputfeatures, maxnewtokens=450, # change as needed returndictingenerate=True, forceddecoder_ids=[[2, 50359], [3, 50363]], # forced to transcribe any language with no timestamps ) return {"sequences": outputs["sequences"]}

@tf.function( inputsignature=[ tf.TensorSpec((1, 80, 3000), tf.float32, name="inputfeatures"), ], ) def translate(self, inputfeatures): outputs = self.model.generate( inputfeatures, maxnewtokens=450, # change as needed returndictingenerate=True, forceddecoder_ids=[[2, 50358], [3, 50363]], # forced to translate any language with no timestamps ) return {"sequences": outputs["sequences"]}

In order to force transcription for a certain language set the 1. decoder id as shown below:

def transcribe(self, inputfeatures): outputs = self.model.generate( inputfeatures, maxnewtokens=450, # change as needed returndictingenerate=True, forceddecoder_ids=[[1, 50261], [2, 50359], [3, 50363]], # forced to transcribe (50359) German (50261) with no timestamps (50363) ) return {"sequences": outputs["sequences"]}

def translate(self, inputfeatures): outputs = self.model.generate( inputfeatures, maxnewtokens=450, # change as needed returndictingenerate=True, forceddecoderids=[[1, 50261], [2, 50358], [3, 50363]], # different forceddecoder_ids ) return {"sequences": outputs["sequences"]}

(language codes from here: https://github.com/woheller69/whisperIME/blob/master/app/src/main/java/com/whispertflite/utils/InputLang.java)

bibtex

The models are based on:

@misc{radford2022whisper,
  doi = {10.48550/ARXIV.2212.04356},
  url = {https://arxiv.org/abs/2212.04356},
  author = {Radford, Alec and Kim, Jong Wook and Xu, Tao and Brockman, Greg and McLeavey, Christine and Sutskever, Ilya},
  title = {Robust Speech Recognition via Large-Scale Weak Supervision},
  publisher = {arXiv},
  year = {2022},
  copyright = {arXiv.org perpetual, non-exclusive license}
}

Conversion to tflite is based on:

@misc{nyadla-sys,
  author={Niranjan Yadla},
  title={{Whisper TFLite: OpenAI Whisper Model Port for Edge Devices}},
  year=2022,
  howpublished={GitHub Repository},
  url={https://github.com/nyadla-sys/whisper.tflite},
  note={Original TFLite implementation of OpenAI Whisper for on-device automatic speech recognition}
}