Make const functions receive const ModelState pointers

This commit is contained in:
Reuben Morais 2020-02-25 11:15:45 +01:00
parent 1f1f5a98e4
commit b74738a405
4 changed files with 10 additions and 10 deletions

View File

@ -77,7 +77,7 @@ struct StreamingState {
~StreamingState();
void feedAudioContent(const short* buffer, unsigned int buffer_size);
char* intermediateDecode();
char* intermediateDecode() const;
void finalizeStream();
char* finishStream();
Metadata* finishStreamWithMetadata();
@ -131,7 +131,7 @@ StreamingState::feedAudioContent(const short* buffer,
}
char*
StreamingState::intermediateDecode()
StreamingState::intermediateDecode() const
{
return model_->decode(decoder_state_);
}
@ -298,7 +298,7 @@ DS_CreateModel(const char* aModelPath,
}
unsigned int
DS_GetModelBeamWidth(ModelState* aCtx)
DS_GetModelBeamWidth(const ModelState* aCtx)
{
return aCtx->beam_width_;
}
@ -311,7 +311,7 @@ DS_SetModelBeamWidth(ModelState* aCtx, unsigned int aBeamWidth)
}
int
DS_GetModelSampleRate(ModelState* aCtx)
DS_GetModelSampleRate(const ModelState* aCtx)
{
return aCtx->sample_rate_;
}
@ -397,7 +397,7 @@ DS_FeedAudioContent(StreamingState* aSctx,
}
char*
DS_IntermediateDecode(StreamingState* aSctx)
DS_IntermediateDecode(const StreamingState* aSctx)
{
return aSctx->intermediateDecode();
}

View File

@ -96,7 +96,7 @@ int DS_CreateModel(const char* aModelPath,
* @return Beam width value used by the model.
*/
DEEPSPEECH_EXPORT
unsigned int DS_GetModelBeamWidth(ModelState* aCtx);
unsigned int DS_GetModelBeamWidth(const ModelState* aCtx);
/**
* @brief Set beam width value used by the model.
@ -119,7 +119,7 @@ int DS_SetModelBeamWidth(ModelState* aCtx,
* @return Sample rate expected by the model for its input.
*/
DEEPSPEECH_EXPORT
int DS_GetModelSampleRate(ModelState* aCtx);
int DS_GetModelSampleRate(const ModelState* aCtx);
/**
* @brief Frees associated resources and destroys model object.
@ -233,7 +233,7 @@ void DS_FeedAudioContent(StreamingState* aSctx,
* string using {@link DS_FreeString()}.
*/
DEEPSPEECH_EXPORT
char* DS_IntermediateDecode(StreamingState* aSctx);
char* DS_IntermediateDecode(const StreamingState* aSctx);
/**
* @brief Signal the end of an audio signal to an ongoing streaming

View File

@ -30,7 +30,7 @@ ModelState::init(const char* model_path)
}
char*
ModelState::decode(const DecoderState& state)
ModelState::decode(const DecoderState& state) const
{
vector<Output> out = state.decode();
return strdup(alphabet_.LabelsToString(out[0].tokens).c_str());

View File

@ -60,7 +60,7 @@ struct ModelState {
*
* @return String representing the decoded text.
*/
virtual char* decode(const DecoderState& state);
virtual char* decode(const DecoderState& state) const;
/**
* @brief Return character-level metadata including letter timings.