Views
No views yet
@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"]}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=[[1, 50261], [2, 50359], [3, 50363]], # forced to transcribe (50359) German (50261) with no timestamps (50363)
)
return {"sequences": outputs["sequences"]}
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=[[1, 50261], [2, 50358], [3, 50363]], # different forced_decoder_ids
)
return {"sequences": outputs["sequences"]}1
2The models are based on:
3
4@misc{radford2022whisper,
5 doi = {10.48550/ARXIV.2212.04356},
6 url = {https://arxiv.org/abs/2212.04356},
7 author = {Radford, Alec and Kim, Jong Wook and Xu, Tao and Brockman, Greg and McLeavey, Christine and Sutskever, Ilya},
8 title = {Robust Speech Recognition via Large-Scale Weak Supervision},
9 publisher = {arXiv},
10 year = {2022},
11 copyright = {arXiv.org perpetual, non-exclusive license}
12}
13
14Conversion to tflite is based on:
15
16@misc{nyadla-sys,
17 author={Niranjan Yadla},
18 title={{Whisper TFLite: OpenAI Whisper Model Port for Edge Devices}},
19 year=2022,
20 howpublished={GitHub Repository},
21 url={https://github.com/nyadla-sys/whisper.tflite},
22 note={Original TFLite implementation of OpenAI Whisper for on-device automatic speech recognition}
23}