hf_speech2text#

class besser.bot.nlp.speech2text.hf_speech2text.HFSpeech2Text(nlp_engine)[source]#

Bases: Speech2Text

A Hugging Face Speech2Text.

It loads a Speech2Text Hugging Face model to perform the Speech2Text task.

Warning

Only tested with openai/whisper-* models

Parameters:

nlp_engine (NLPEngine) – the NLPEngine that handles the NLP processes of the bot

_model_name#

the Hugging Face model name

Type:

str

_processor#

the model text processor

_model#

the Speech2Text model

_sampling_rate#

the sampling rate of audio data, it must coincide with the sampling rate used to train the model

Type:

int

_forced_decoder_ids#

the decoder ids

Type:

list

_abc_impl = <_abc._abc_data object>#
speech2text(speech)[source]#

Transcribe a voice audio into its corresponding text representation.

Parameters:

speech (bytes) – the recorded voice that wants to be transcribed

Returns:

the speech transcription

Return type:

str