Skip to content

Commit

Permalink
Make const functions receive const ModelState pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
reuben authored and kdavis-mozilla committed Feb 25, 2020
1 parent 888ddb2 commit 47272a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions native_client/deepspeech.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -131,7 +131,7 @@ StreamingState::feedAudioContent(const short* buffer,
}

char*
StreamingState::intermediateDecode()
StreamingState::intermediateDecode() const
{
return model_->decode(decoder_state_);
}
Expand Down Expand Up @@ -298,7 +298,7 @@ DS_CreateModel(const char* aModelPath,
}

unsigned int
DS_GetModelBeamWidth(ModelState* aCtx)
DS_GetModelBeamWidth(const ModelState* aCtx)
{
return aCtx->beam_width_;
}
Expand All @@ -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_;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ DS_FeedAudioContent(StreamingState* aSctx,
}

char*
DS_IntermediateDecode(StreamingState* aSctx)
DS_IntermediateDecode(const StreamingState* aSctx)
{
return aSctx->intermediateDecode();
}
Expand Down
6 changes: 3 additions & 3 deletions native_client/deepspeech.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion native_client/modelstate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion native_client/modelstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 47272a7

Please sign in to comment.