api_speech2text#

class baf.nlp.speech2text.api_speech2text.APISpeech2Text(agent, sr_engine='Google Speech Recognition', language=None)[source]#

Bases: Speech2Text

Makes use of the python speech_recognition library.

The library calls to different speech recognition engines/APIs.

Currently, supports:

Google Speech Recognition

Parameters:
  • agent (Agent) – the agent instance using this speech-to-text class

  • sr_engine (str, optional) – the chosen speech recognition engine. Defaults to “Google Speech Recognition”.

  • language (str, optional) – the chosen language. Defaults to None.

_sr_engine#

the chosen SR engine

Type:

str

_language#

the chosen language

Type:

str

_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