Move DS_ErrorCodeToErrorMessage impl to its own object so it can be used without including all of libdeepspeech

This commit is contained in:
Reuben Morais 2020-06-26 10:23:46 +02:00
parent 39696f0d67
commit 03ca94887c
3 changed files with 23 additions and 20 deletions

View File

@ -89,13 +89,14 @@ cc_library(
tf_cc_shared_object(
name = "libdeepspeech.so",
srcs = [
"alphabet.h",
"deepspeech.cc",
"deepspeech.h",
"alphabet.h",
"modelstate.h",
"deepspeech_errors.cc",
"modelstate.cc",
"workspace_status.h",
"modelstate.h",
"workspace_status.cc",
"workspace_status.h",
] + select({
"//native_client:tflite": [
"tflitemodelstate.h",

View File

@ -501,20 +501,3 @@ DS_Version()
{
return strdup(ds_version());
}
char*
DS_ErrorCodeToErrorMessage(int aErrorCode)
{
#define RETURN_MESSAGE(NAME, VALUE, DESC) \
case NAME: \
return strdup(DESC);
switch(aErrorCode)
{
DS_FOR_EACH_ERROR(RETURN_MESSAGE)
default:
return strdup("Unknown error, please make sure you are using the correct native binary.");
}
#undef RETURN_MESSAGE
}

View File

@ -0,0 +1,19 @@
#include "deepspeech.h"
#include <string.h>
char*
DS_ErrorCodeToErrorMessage(int aErrorCode)
{
#define RETURN_MESSAGE(NAME, VALUE, DESC) \
case NAME: \
return strdup(DESC);
switch(aErrorCode)
{
DS_FOR_EACH_ERROR(RETURN_MESSAGE)
default:
return strdup("Unknown error, please make sure you are using the correct native binary.");
}
#undef RETURN_MESSAGE
}