Expose DS error codes in ds_ctcdecoder package

This commit is contained in:
Reuben Morais 2020-05-18 17:28:02 +02:00
parent afb8c55b6e
commit 4db20b3cd6
2 changed files with 12 additions and 0 deletions

View File

@ -5,6 +5,12 @@ from .swigwrapper import Alphabet
__version__ = swigwrapper.__version__
# Hack: import error codes by matching on their names, as SWIG unfortunately
# does not support binding enums to Python in a scoped manner yet.
for symbol in dir(swigwrapper):
if symbol.startswith('DS_ERR_'):
globals()[symbol] = getattr(swigwrapper, symbol)
class Scorer(swigwrapper.Scorer):
"""Wrapper for Scorer.

View File

@ -41,3 +41,9 @@ namespace std {
%template(IntVector) std::vector<int>;
%template(OutputVector) std::vector<Output>;
%template(OutputVectorVector) std::vector<std::vector<Output>>;
// Import only the error code enum definitions from deepspeech.h
%ignore "";
%rename("%s", regexmatch$name="DS_ERR_") "";
%rename("%s", regexmatch$name="DeepSpeech_Error_Codes") "";
%include "../deepspeech.h"