Remove unused params and make function names more consistent
This commit is contained in:
parent
896ac9d6c7
commit
c402b971d6
@ -257,8 +257,6 @@ StreamingState::processBatch(const vector<float>& buf, unsigned int n_steps)
|
||||
|
||||
int
|
||||
DS_CreateModel(const char* aModelPath,
|
||||
unsigned int aNCep,
|
||||
unsigned int aNContext,
|
||||
const char* aAlphabetConfigPath,
|
||||
unsigned int aBeamWidth,
|
||||
ModelState** retval)
|
||||
@ -285,7 +283,7 @@ DS_CreateModel(const char* aModelPath,
|
||||
return DS_ERR_FAIL_CREATE_MODEL;
|
||||
}
|
||||
|
||||
int err = model->init(aModelPath, aNCep, aNContext, aAlphabetConfigPath, aBeamWidth);
|
||||
int err = model->init(aModelPath, aAlphabetConfigPath, aBeamWidth);
|
||||
if (err != DS_ERR_OK) {
|
||||
return err;
|
||||
}
|
||||
@ -295,14 +293,13 @@ DS_CreateModel(const char* aModelPath,
|
||||
}
|
||||
|
||||
void
|
||||
DS_DestroyModel(ModelState* ctx)
|
||||
DS_FreeModel(ModelState* ctx)
|
||||
{
|
||||
delete ctx;
|
||||
}
|
||||
|
||||
int
|
||||
DS_EnableDecoderWithLM(ModelState* aCtx,
|
||||
const char* aAlphabetConfigPath,
|
||||
const char* aLMPath,
|
||||
const char* aTriePath,
|
||||
float aLMAlpha,
|
||||
@ -320,9 +317,9 @@ DS_EnableDecoderWithLM(ModelState* aCtx,
|
||||
}
|
||||
|
||||
int
|
||||
DS_SetupStream(ModelState* aCtx,
|
||||
unsigned int aSampleRate,
|
||||
StreamingState** retval)
|
||||
DS_CreateStream(ModelState* aCtx,
|
||||
unsigned int aSampleRate,
|
||||
StreamingState** retval)
|
||||
{
|
||||
*retval = nullptr;
|
||||
|
||||
@ -371,7 +368,7 @@ char*
|
||||
DS_FinishStream(StreamingState* aSctx)
|
||||
{
|
||||
char* str = aSctx->finishStream();
|
||||
DS_DiscardStream(aSctx);
|
||||
DS_FreeStream(aSctx);
|
||||
return str;
|
||||
}
|
||||
|
||||
@ -379,18 +376,18 @@ Metadata*
|
||||
DS_FinishStreamWithMetadata(StreamingState* aSctx)
|
||||
{
|
||||
Metadata* metadata = aSctx->finishStreamWithMetadata();
|
||||
DS_DiscardStream(aSctx);
|
||||
DS_FreeStream(aSctx);
|
||||
return metadata;
|
||||
}
|
||||
|
||||
StreamingState*
|
||||
SetupStreamAndFeedAudioContent(ModelState* aCtx,
|
||||
const short* aBuffer,
|
||||
unsigned int aBufferSize,
|
||||
unsigned int aSampleRate)
|
||||
CreateStreamAndFeedAudioContent(ModelState* aCtx,
|
||||
const short* aBuffer,
|
||||
unsigned int aBufferSize,
|
||||
unsigned int aSampleRate)
|
||||
{
|
||||
StreamingState* ctx;
|
||||
int status = DS_SetupStream(aCtx, aSampleRate, &ctx);
|
||||
int status = DS_CreateStream(aCtx, aSampleRate, &ctx);
|
||||
if (status != DS_ERR_OK) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -404,7 +401,7 @@ DS_SpeechToText(ModelState* aCtx,
|
||||
unsigned int aBufferSize,
|
||||
unsigned int aSampleRate)
|
||||
{
|
||||
StreamingState* ctx = SetupStreamAndFeedAudioContent(aCtx, aBuffer, aBufferSize, aSampleRate);
|
||||
StreamingState* ctx = CreateStreamAndFeedAudioContent(aCtx, aBuffer, aBufferSize, aSampleRate);
|
||||
return DS_FinishStream(ctx);
|
||||
}
|
||||
|
||||
@ -414,12 +411,12 @@ DS_SpeechToTextWithMetadata(ModelState* aCtx,
|
||||
unsigned int aBufferSize,
|
||||
unsigned int aSampleRate)
|
||||
{
|
||||
StreamingState* ctx = SetupStreamAndFeedAudioContent(aCtx, aBuffer, aBufferSize, aSampleRate);
|
||||
StreamingState* ctx = CreateStreamAndFeedAudioContent(aCtx, aBuffer, aBufferSize, aSampleRate);
|
||||
return DS_FinishStreamWithMetadata(ctx);
|
||||
}
|
||||
|
||||
void
|
||||
DS_DiscardStream(StreamingState* aSctx)
|
||||
DS_FreeStream(StreamingState* aSctx)
|
||||
{
|
||||
delete aSctx;
|
||||
}
|
||||
|
@ -63,8 +63,6 @@ enum DeepSpeech_Error_Codes
|
||||
* @brief An object providing an interface to a trained DeepSpeech model.
|
||||
*
|
||||
* @param aModelPath The path to the frozen model graph.
|
||||
* @param aNCep The number of cepstrum the model was trained with.
|
||||
* @param aNContext The context window the model was trained with.
|
||||
* @param aAlphabetConfigPath The path to the configuration file specifying
|
||||
* the alphabet used by the network. See alphabet.h.
|
||||
* @param aBeamWidth The beam width used by the decoder. A larger beam
|
||||
@ -76,8 +74,6 @@ enum DeepSpeech_Error_Codes
|
||||
*/
|
||||
DEEPSPEECH_EXPORT
|
||||
int DS_CreateModel(const char* aModelPath,
|
||||
unsigned int aNCep,
|
||||
unsigned int aNContext,
|
||||
const char* aAlphabetConfigPath,
|
||||
unsigned int aBeamWidth,
|
||||
ModelState** retval);
|
||||
@ -86,7 +82,7 @@ int DS_CreateModel(const char* aModelPath,
|
||||
* @brief Frees associated resources and destroys model object.
|
||||
*/
|
||||
DEEPSPEECH_EXPORT
|
||||
void DS_DestroyModel(ModelState* ctx);
|
||||
void DS_FreeModel(ModelState* ctx);
|
||||
|
||||
/**
|
||||
* @brief Enable decoding using beam scoring with a KenLM language model.
|
||||
@ -106,7 +102,6 @@ void DS_DestroyModel(ModelState* ctx);
|
||||
*/
|
||||
DEEPSPEECH_EXPORT
|
||||
int DS_EnableDecoderWithLM(ModelState* aCtx,
|
||||
const char* aAlphabetConfigPath,
|
||||
const char* aLMPath,
|
||||
const char* aTriePath,
|
||||
float aLMAlpha,
|
||||
@ -145,9 +140,9 @@ char* DS_SpeechToText(ModelState* aCtx,
|
||||
*/
|
||||
DEEPSPEECH_EXPORT
|
||||
Metadata* DS_SpeechToTextWithMetadata(ModelState* aCtx,
|
||||
const short* aBuffer,
|
||||
unsigned int aBufferSize,
|
||||
unsigned int aSampleRate);
|
||||
const short* aBuffer,
|
||||
unsigned int aBufferSize,
|
||||
unsigned int aSampleRate);
|
||||
|
||||
/**
|
||||
* @brief Create a new streaming inference state. The streaming state returned
|
||||
@ -162,14 +157,14 @@ Metadata* DS_SpeechToTextWithMetadata(ModelState* aCtx,
|
||||
* @return Zero for success, non-zero on failure.
|
||||
*/
|
||||
DEEPSPEECH_EXPORT
|
||||
int DS_SetupStream(ModelState* aCtx,
|
||||
unsigned int aSampleRate,
|
||||
StreamingState** retval);
|
||||
int DS_CreateStream(ModelState* aCtx,
|
||||
unsigned int aSampleRate,
|
||||
StreamingState** retval);
|
||||
|
||||
/**
|
||||
* @brief Feed audio samples to an ongoing streaming inference.
|
||||
*
|
||||
* @param aSctx A streaming state pointer returned by {@link DS_SetupStream()}.
|
||||
* @param aSctx A streaming state pointer returned by {@link DS_CreateStream()}.
|
||||
* @param aBuffer An array of 16-bit, mono raw audio samples at the
|
||||
* appropriate sample rate.
|
||||
* @param aBufferSize The number of samples in @p aBuffer.
|
||||
@ -185,7 +180,7 @@ void DS_FeedAudioContent(StreamingState* aSctx,
|
||||
* currently capable of streaming, so it always starts from the beginning
|
||||
* of the audio.
|
||||
*
|
||||
* @param aSctx A streaming state pointer returned by {@link DS_SetupStream()}.
|
||||
* @param aSctx A streaming state pointer returned by {@link DS_CreateStream()}.
|
||||
*
|
||||
* @return The STT intermediate result. The user is responsible for freeing the
|
||||
* string using {@link DS_FreeString()}.
|
||||
@ -197,7 +192,7 @@ char* DS_IntermediateDecode(StreamingState* aSctx);
|
||||
* @brief Signal the end of an audio signal to an ongoing streaming
|
||||
* inference, returns the STT result over the whole audio signal.
|
||||
*
|
||||
* @param aSctx A streaming state pointer returned by {@link DS_SetupStream()}.
|
||||
* @param aSctx A streaming state pointer returned by {@link DS_CreateStream()}.
|
||||
*
|
||||
* @return The STT result. The user is responsible for freeing the string using
|
||||
* {@link DS_FreeString()}.
|
||||
@ -211,7 +206,7 @@ char* DS_FinishStream(StreamingState* aSctx);
|
||||
* @brief Signal the end of an audio signal to an ongoing streaming
|
||||
* inference, returns per-letter metadata.
|
||||
*
|
||||
* @param aSctx A streaming state pointer returned by {@link DS_SetupStream()}.
|
||||
* @param aSctx A streaming state pointer returned by {@link DS_CreateStream()}.
|
||||
*
|
||||
* @return Outputs a struct of individual letters along with their timing information.
|
||||
* The user is responsible for freeing Metadata by calling {@link DS_FreeMetadata()}. Returns NULL on error.
|
||||
@ -226,12 +221,12 @@ Metadata* DS_FinishStreamWithMetadata(StreamingState* aSctx);
|
||||
* can be used if you no longer need the result of an ongoing streaming
|
||||
* inference and don't want to perform a costly decode operation.
|
||||
*
|
||||
* @param aSctx A streaming state pointer returned by {@link DS_SetupStream()}.
|
||||
* @param aSctx A streaming state pointer returned by {@link DS_CreateStream()}.
|
||||
*
|
||||
* @note This method will free the state pointer (@p aSctx).
|
||||
*/
|
||||
DEEPSPEECH_EXPORT
|
||||
void DS_DiscardStream(StreamingState* aSctx);
|
||||
void DS_FreeStream(StreamingState* aSctx);
|
||||
|
||||
/**
|
||||
* @brief Free memory allocated for metadata information.
|
||||
|
@ -25,13 +25,9 @@ ModelState::~ModelState()
|
||||
|
||||
int
|
||||
ModelState::init(const char* model_path,
|
||||
unsigned int n_features,
|
||||
unsigned int n_context,
|
||||
const char* alphabet_path,
|
||||
unsigned int beam_width)
|
||||
{
|
||||
n_features_ = n_features;
|
||||
n_context_ = n_context;
|
||||
if (alphabet_.init(alphabet_path)) {
|
||||
return DS_ERR_INVALID_ALPHABET;
|
||||
}
|
||||
|
@ -35,8 +35,6 @@ struct ModelState {
|
||||
virtual ~ModelState();
|
||||
|
||||
virtual int init(const char* model_path,
|
||||
unsigned int n_features,
|
||||
unsigned int n_context,
|
||||
const char* alphabet_path,
|
||||
unsigned int beam_width);
|
||||
|
||||
|
@ -89,12 +89,10 @@ TFLiteModelState::~TFLiteModelState()
|
||||
|
||||
int
|
||||
TFLiteModelState::init(const char* model_path,
|
||||
unsigned int n_features,
|
||||
unsigned int n_context,
|
||||
const char* alphabet_path,
|
||||
unsigned int beam_width)
|
||||
{
|
||||
int err = ModelState::init(model_path, n_features, n_context, alphabet_path, beam_width);
|
||||
int err = ModelState::init(model_path, alphabet_path, beam_width);
|
||||
if (err != DS_ERR_OK) {
|
||||
return err;
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ struct TFLiteModelState : public ModelState
|
||||
virtual ~TFLiteModelState();
|
||||
|
||||
virtual int init(const char* model_path,
|
||||
unsigned int n_features,
|
||||
unsigned int n_context,
|
||||
const char* alphabet_path,
|
||||
unsigned int beam_width) override;
|
||||
|
||||
|
@ -25,12 +25,10 @@ TFModelState::~TFModelState()
|
||||
|
||||
int
|
||||
TFModelState::init(const char* model_path,
|
||||
unsigned int n_features,
|
||||
unsigned int n_context,
|
||||
const char* alphabet_path,
|
||||
unsigned int beam_width)
|
||||
{
|
||||
int err = ModelState::init(model_path, n_features, n_context, alphabet_path, beam_width);
|
||||
int err = ModelState::init(model_path, alphabet_path, beam_width);
|
||||
if (err != DS_ERR_OK) {
|
||||
return err;
|
||||
}
|
||||
|
@ -19,8 +19,6 @@ struct TFModelState : public ModelState
|
||||
virtual ~TFModelState();
|
||||
|
||||
virtual int init(const char* model_path,
|
||||
unsigned int n_features,
|
||||
unsigned int n_context,
|
||||
const char* alphabet_path,
|
||||
unsigned int beam_width) override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user