|
--- |
|
license: mit |
|
pipeline_tag: automatic-speech-recognition |
|
--- |
|
|
|
# Whisper tflite models for use in Whisper app on F-Droid |
|
|
|
"transcribe-translate" models provide signatures for "serving_transcribe" and "serving_translate" to force the model to perform a certain action |
|
|
|
|
|
@tf.function( |
|
input_signature=[ |
|
tf.TensorSpec((1, 80, 3000), tf.float32, name="input_features"), |
|
], |
|
) |
|
def transcribe(self, input_features): |
|
outputs = self.model.generate( |
|
input_features, |
|
max_new_tokens=450, # change as needed |
|
return_dict_in_generate=True, |
|
forced_decoder_ids=[[2, 50359], [3, 50363]], # forced to transcribe any language with no timestamps |
|
) |
|
return {"sequences": outputs["sequences"]} |
|
|
|
@tf.function( |
|
input_signature=[ |
|
tf.TensorSpec((1, 80, 3000), tf.float32, name="input_features"), |
|
], |
|
) |
|
def translate(self, input_features): |
|
outputs = self.model.generate( |
|
input_features, |
|
max_new_tokens=450, # change as needed |
|
return_dict_in_generate=True, |
|
forced_decoder_ids=[[2, 50358], [3, 50363]], # forced to translate any language with no timestamps |
|
) |
|
return {"sequences": outputs["sequences"]} |
|
|
|
|