Merge pull request #2767 from reuben/readable_repr_bindings
Add a better __repr__ for Metadata objects in Python bindings
This commit is contained in:
commit
44ff4c54b9
|
@ -46,6 +46,23 @@ import_array();
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%extend struct MetadataItem {
|
||||||
|
%pythoncode %{
|
||||||
|
def __repr__(self):
|
||||||
|
return 'MetadataItem(character=\'{}\', timestep={}, start_time={})'.format(self.character, self.timestep, self.start_time)
|
||||||
|
%}
|
||||||
|
}
|
||||||
|
|
||||||
|
%extend struct Metadata {
|
||||||
|
%pythoncode %{
|
||||||
|
def __repr__(self):
|
||||||
|
items_repr = ', \n'.join(' ' + repr(i) for i in self.items)
|
||||||
|
return 'Metadata(confidence={}, items=[\n{}\n])'.format(self.confidence, items_repr)
|
||||||
|
%}
|
||||||
|
}
|
||||||
|
|
||||||
|
%ignore Metadata::num_items;
|
||||||
|
|
||||||
%extend struct Metadata {
|
%extend struct Metadata {
|
||||||
~Metadata() {
|
~Metadata() {
|
||||||
DS_FreeMetadata($self);
|
DS_FreeMetadata($self);
|
||||||
|
|
|
@ -64,7 +64,7 @@ def main():
|
||||||
include_dirs=[numpy_include, '../'],
|
include_dirs=[numpy_include, '../'],
|
||||||
library_dirs=list(map(lambda x: x.strip(), lib_dirs_split(os.getenv('MODEL_LDFLAGS', '')))),
|
library_dirs=list(map(lambda x: x.strip(), lib_dirs_split(os.getenv('MODEL_LDFLAGS', '')))),
|
||||||
libraries=list(map(lambda x: x.strip(), libs_split(os.getenv('MODEL_LIBS', '')))),
|
libraries=list(map(lambda x: x.strip(), libs_split(os.getenv('MODEL_LIBS', '')))),
|
||||||
swig_opts=['-c++', '-keyword', '-builtin'])
|
swig_opts=['-c++', '-keyword'])
|
||||||
|
|
||||||
setup(name=project_name,
|
setup(name=project_name,
|
||||||
description='A library for running inference on a DeepSpeech model',
|
description='A library for running inference on a DeepSpeech model',
|
||||||
|
|
Loading…
Reference in New Issue