vsdk 12.0.0
 
Loading...
Searching...
No Matches
Vsdk::Asr::Recognizerabstract

ConsumerModule that performs Automatic Speech Recognition. More...

#include <Recognizer.hpp>

Inheritance diagram for Vsdk::Asr::Recognizer:
Vsdk::Audio::ConsumerModule

Public Member Functions

 ~Recognizer () override
 
auto name () const -> std::string const &
 Name of this particular Recognizer instance.
 
auto upTime () const -> int
 Amount of milliseconds of audio processed for the current model(s), expressed as int.
 
auto upTimeMs () const -> std::chrono::milliseconds
 Amount of milliseconds of audio processed for the current model(s), expressed as std::chrono::milliseconds.
 
virtual void setModel (std::string const &model, int startTime)=0
 Applies a new recognition model.
 
void setModel (std::string const &model)
 Applies a new recognition model.
 
virtual void setModels (std::unordered_set< std::string > const &models, int startTime)=0
 Applies multiple recognition models at the same time.
 
void setModels (std::unordered_set< std::string > const &models)
 Applies multiple recognition models at the same time.
 
Addon::EntryPoint * postProcessor () const
 Get the active ASR post-processor entry point.
 
- Public Member Functions inherited from Vsdk::Audio::ConsumerModule
 ConsumerModule ()
 
virtual ~ConsumerModule ()
 

Protected Member Functions

 Recognizer (std::string name)
 
virtual void configure (nlohmann::json const &)
 
virtual bool processBuffer (Audio::Buffer const &buffer, bool last)=0
 
void dispatchResult (ResultType resultType, std::string typeString, nlohmann::json result, bool isFinal) const override
 
void dispatchEvent (EventCode code, std::string message, std::chrono::milliseconds time)
 
void dispatchError (ErrorType type, ErrorCode code, std::string message=std::string())
 
void setUpTime (double upTime)
 
bool userWordEnrollmentEnabled () const
 Whether user-word enrolling is enabled.
 
void setUserWordEnrollmentEnabled (bool enabled)
 
auto userWordStatusReporter () -> details::StatusReporter< RecognizerEventCode, RecognizerErrorCode > &
 

Protected Attributes

std::string _name
 
double _upTime
 
Addon::ASRPostProcessorPtr _postProcessor
 
RecognizerEventCode _lastEventCode
 

Detailed Description

ConsumerModule that performs Automatic Speech Recognition.

Constructor & Destructor Documentation

◆ Recognizer()

Recognizer::Recognizer ( std::string  name)
explicitprotected

◆ ~Recognizer()

Recognizer::~Recognizer ( )
override

Member Function Documentation

◆ name()

auto Recognizer::name ( ) const -> std::string const &

Name of this particular Recognizer instance.

◆ upTime()

auto Recognizer::upTime ( ) const -> int

Amount of milliseconds of audio processed for the current model(s), expressed as int.

◆ upTimeMs()

auto Recognizer::upTimeMs ( ) const -> std::chrono::milliseconds

Amount of milliseconds of audio processed for the current model(s), expressed as std::chrono::milliseconds.

◆ setModel() [1/2]

virtual void Vsdk::Asr::Recognizer::setModel ( std::string const &  model,
int  startTime 
)
pure virtual

Applies a new recognition model.

Parameters
modelFound in the configuration under asr.models
startTimeTime from which the recognizer starts processing audio again. This is usually taken from a previous result, like so:
setModel(model, hypothesis["end_time"].get<int>());
virtual void setModel(std::string const &model, int startTime)=0
Applies a new recognition model.
Note
Some implementations do not support the startTime parameter and will recognize again starting from the moment the model is fully loaded

◆ setModel() [2/2]

void Recognizer::setModel ( std::string const &  model)

Applies a new recognition model.

Equivalent to calling:

setModel(model, -1);

◆ setModels() [1/2]

virtual void Vsdk::Asr::Recognizer::setModels ( std::unordered_set< std::string > const &  models,
int  startTime 
)
pure virtual

Applies multiple recognition models at the same time.

Parameters
modelsFound in the configuration under asr.models
startTimeTime from which the recognizer starts processing audio again. This is usually taken from a previous result, like so:
setModel(model, hypothesis["end_time"].get<int>());
Note
Some implementations do not support the startTime parameter and will recognize again starting from the moment the models are fully loaded

◆ setModels() [2/2]

void Recognizer::setModels ( std::unordered_set< std::string > const &  models)

Applies multiple recognition models at the same time.

Equivalent to calling:

setModels(models, -1);
virtual void setModels(std::unordered_set< std::string > const &models, int startTime)=0
Applies multiple recognition models at the same time.

◆ postProcessor()

Addon::EntryPoint * Vsdk::Asr::Recognizer::postProcessor ( ) const

Get the active ASR post-processor entry point.

Returns a pointer to the EntryPoint interface of the currently configured ASR post-processor. This allows you to invoke commands or operations on the plugin through the generic dispatch mechanism

Returns
Pointer to the associated Addon::EntryPoint, or nullptr if no post-processor is configured.
See also
Addon::EntryPoint::invoke()

◆ configure()

virtual void Vsdk::Asr::Recognizer::configure ( nlohmann::json const &  )
protectedvirtual

◆ processBuffer()

virtual bool Vsdk::Asr::Recognizer::processBuffer ( Audio::Buffer const &  buffer,
bool  last 
)
protectedpure virtual
Returns
true if the buffer has been processed, else false

◆ dispatchResult()

void Recognizer::dispatchResult ( ResultType  resultType,
std::string  typeString,
nlohmann::json  result,
bool  isFinal 
) const
overrideprotected

◆ dispatchEvent()

void Recognizer::dispatchEvent ( EventCode  code,
std::string  message,
std::chrono::milliseconds  time 
)
protected

◆ dispatchError()

void Recognizer::dispatchError ( ErrorType  type,
ErrorCode  code,
std::string  message = std::string() 
)
protected

◆ setUpTime()

void Recognizer::setUpTime ( double  upTime)
protected

◆ userWordEnrollmentEnabled()

bool Recognizer::userWordEnrollmentEnabled ( ) const
protected

Whether user-word enrolling is enabled.

◆ setUserWordEnrollmentEnabled()

void Recognizer::setUserWordEnrollmentEnabled ( bool  enabled)
protected

◆ userWordStatusReporter()

auto Recognizer::userWordStatusReporter ( ) -> details::StatusReporter<RecognizerEventCode, RecognizerErrorCode> &
protected

Member Data Documentation

◆ _name

std::string Vsdk::Asr::Recognizer::_name
protected

◆ _upTime

double Vsdk::Asr::Recognizer::_upTime
protected

◆ _postProcessor

Addon::ASRPostProcessorPtr Vsdk::Asr::Recognizer::_postProcessor
protected

◆ _lastEventCode

RecognizerEventCode Vsdk::Asr::Recognizer::_lastEventCode
protected