diff --git a/native_client/deepspeech.cc b/native_client/deepspeech.cc index c500fc83..539cafd2 100644 --- a/native_client/deepspeech.cc +++ b/native_client/deepspeech.cc @@ -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(); } diff --git a/native_client/deepspeech.h b/native_client/deepspeech.h index 53e93ec3..ca20c011 100644 --- a/native_client/deepspeech.h +++ b/native_client/deepspeech.h @@ -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 diff --git a/native_client/modelstate.cc b/native_client/modelstate.cc index 4bc0e953..ea8928bd 100644 --- a/native_client/modelstate.cc +++ b/native_client/modelstate.cc @@ -30,7 +30,7 @@ ModelState::init(const char* model_path) } char* -ModelState::decode(const DecoderState& state) +ModelState::decode(const DecoderState& state) const { vector out = state.decode(); return strdup(alphabet_.LabelsToString(out[0].tokens).c_str()); diff --git a/native_client/modelstate.h b/native_client/modelstate.h index c296c003..25251e15 100644 --- a/native_client/modelstate.h +++ b/native_client/modelstate.h @@ -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.