sherpa-onnx C API 1.0
Public C API and C++ wrapper for sherpa-onnx
Loading...
Searching...
No Matches
sherpa_onnx::cxx::OnlineRecognizer Class Reference

RAII wrapper for a streaming recognizer. More...

#include <cxx-api.h>

+ Inheritance diagram for sherpa_onnx::cxx::OnlineRecognizer:
+ Collaboration diagram for sherpa_onnx::cxx::OnlineRecognizer:

Public Member Functions

void Destroy (const SherpaOnnxOnlineRecognizer *p) const
 Destroy the wrapped C handle.
 
OnlineStream CreateStream () const
 Create a stream that uses the recognizer's configured hotwords.
 
OnlineStream CreateStream (const std::string &hotwords) const
 Create a stream with inline hotwords.
 
bool IsReady (const OnlineStream *s) const
 Check whether the given stream has enough data to decode.
 
void Decode (const OnlineStream *s) const
 Decode one ready stream.
 
void Decode (const OnlineStream *ss, int32_t n) const
 Decode multiple ready streams in parallel.
 
OnlineRecognizerResult GetResult (const OnlineStream *s) const
 Return the current recognition result for a stream.
 
void Reset (const OnlineStream *s) const
 Reset a stream after endpointing or utterance completion.
 
bool IsEndpoint (const OnlineStream *s) const
 Check whether endpointing has triggered for a stream.
 
- Public Member Functions inherited from sherpa_onnx::cxx::MoveOnly< OnlineRecognizer, SherpaOnnxOnlineRecognizer >
 MoveOnly ()=default
 Construct an empty wrapper.
 
 MoveOnly (const SherpaOnnxOnlineRecognizer *p)
 Construct a wrapper from a raw C handle.
 
 MoveOnly (const MoveOnly &)=delete
 
 MoveOnly (MoveOnly &&other)
 
 ~MoveOnly ()
 Destroy the wrapped handle if present.
 
MoveOnlyoperator= (const MoveOnly &)=delete
 
MoveOnlyoperator= (MoveOnly &&other)
 
const SherpaOnnxOnlineRecognizerGet () const
 Return the wrapped raw pointer without transferring ownership.
 
const SherpaOnnxOnlineRecognizerRelease ()
 Release ownership of the wrapped raw pointer.
 

Static Public Member Functions

static OnlineRecognizer Create (const OnlineRecognizerConfig &config)
 Create a streaming recognizer from a config struct.
 

Additional Inherited Members

- Protected Attributes inherited from sherpa_onnx::cxx::MoveOnly< OnlineRecognizer, SherpaOnnxOnlineRecognizer >
const SherpaOnnxOnlineRecognizerp_
 

Detailed Description

Example:

OnlineStream stream = recognizer.CreateStream();
stream.AcceptWaveform(wave.sample_rate, wave.samples.data(),
wave.samples.size());
stream.InputFinished();
while (recognizer.IsReady(&stream)) {
recognizer.Decode(&stream);
}
auto result = recognizer.GetResult(&stream);
RAII wrapper for a streaming recognizer.
Definition cxx-api.h:385
void Decode(const OnlineStream *s) const
Decode one ready stream.
OnlineRecognizerResult GetResult(const OnlineStream *s) const
Return the current recognition result for a stream.
static OnlineRecognizer Create(const OnlineRecognizerConfig &config)
Create a streaming recognizer from a config struct.
bool IsReady(const OnlineStream *s) const
Check whether the given stream has enough data to decode.
OnlineStream CreateStream() const
Create a stream that uses the recognizer's configured hotwords.
void InputFinished() const
Indicate that no more input audio will be provided.
void AcceptWaveform(int32_t sample_rate, const float *samples, int32_t n) const
Append audio samples to the stream.

Definition at line 384 of file cxx-api.h.

Member Function Documentation

◆ Create()

static OnlineRecognizer sherpa_onnx::cxx::OnlineRecognizer::Create ( const OnlineRecognizerConfig config)
static

◆ CreateStream() [1/2]

OnlineStream sherpa_onnx::cxx::OnlineRecognizer::CreateStream ( ) const

◆ CreateStream() [2/2]

OnlineStream sherpa_onnx::cxx::OnlineRecognizer::CreateStream ( const std::string &  hotwords) const

◆ Decode() [1/2]

void sherpa_onnx::cxx::OnlineRecognizer::Decode ( const OnlineStream s) const

◆ Decode() [2/2]

void sherpa_onnx::cxx::OnlineRecognizer::Decode ( const OnlineStream ss,
int32_t  n 
) const

◆ Destroy()

void sherpa_onnx::cxx::OnlineRecognizer::Destroy ( const SherpaOnnxOnlineRecognizer p) const

◆ GetResult()

OnlineRecognizerResult sherpa_onnx::cxx::OnlineRecognizer::GetResult ( const OnlineStream s) const

◆ IsEndpoint()

bool sherpa_onnx::cxx::OnlineRecognizer::IsEndpoint ( const OnlineStream s) const

◆ IsReady()

bool sherpa_onnx::cxx::OnlineRecognizer::IsReady ( const OnlineStream s) const

◆ Reset()

void sherpa_onnx::cxx::OnlineRecognizer::Reset ( const OnlineStream s) const

The documentation for this class was generated from the following file: