Skip to content

Commit

Permalink
add scorer functions in src files
Browse files Browse the repository at this point in the history
  • Loading branch information
manuindersekhon committed May 20, 2022
1 parent 4e49faf commit 84ef8d5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
21 changes: 21 additions & 0 deletions libc_deepspeech/libc_deepspeech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,24 @@ char *speech_to_text(void *model_state, char *buffer, uint64_t buffer_size)

return encoded;
}

int enable_external_scorer(void *model_state, char *model_path)
{
ModelState *ptr = (ModelState *)model_state;
int status = DS_EnableExternalScorer(ptr, model_path);
return status;
}

int disable_external_scorer(void *model_state)
{
ModelState *ptr = (ModelState *)model_state;
int status = DS_DisableExternalScorer(ptr);
return status;
}

int set_scorer_alpha_beta(void *model_state, float alpha, float beta)
{
ModelState *ptr = (ModelState *)model_state;
int status = DS_SetScorerAlphaBeta(ptr, alpha, beta);
return status;
}
14 changes: 13 additions & 1 deletion libc_deepspeech/libc_deepspeech.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@ extern "C"
// Returns json output from speech to text engine.
EXPORTED char *speech_to_text(void *model_state, char *buffer, uint64_t buffer_size);

// Closing bracket for extern "C"
// Enable decoding using external scorer. Returns zero on success, non-zero on failure.
EXPORTED int enable_external_scorer(void *model_state, char *scorer_file_path);

// Disable decoding using external scorer. Returns zero on success, non-zero on failure.
EXPORTED int disable_external_scorer(void *model_state);

// Set hyperparameters alpha and beta of the external scorer. Returns zero on success, non-zero on failure.
// @param alpha: The alpha hyperparameter of the decoder. Language model weight.
// @param beta: The beta hyperparameter of the decoder. Word insertion weight.
EXPORTED int set_scorer_alpha_beta(void *model_state, float alpha, float beta);


// Closing bracket for extern "C"
#ifdef __cplusplus
}
#endif

0 comments on commit 84ef8d5

Please sign in to comment.