Giter VIP home page Giter VIP logo

py-kaldi-asr's Introduction

py-kaldi-asr

Some simple wrappers around kaldi-asr intended to make using kaldi's online nnet3-chain decoders as convenient as possible. Kaldi's online GMM decoders are also supported.

Target audience are developers who would like to use kaldi-asr as-is for speech recognition in their application on GNU/Linux operating systems.

Constructive comments, patches and pull-requests are very welcome.

Getting Started

We recommend using pre-trained modules from the zamia-speech project to get started. There you will also find a tutorial complete with links to pre-built binary packages to get you up and running with free and open source speech recognition in a matter of minutes:

Zamia Speech Tutorial

Example Code

Simple wav file decoding:

from kaldiasr.nnet3 import KaldiNNet3OnlineModel, KaldiNNet3OnlineDecoder

MODELDIR    = 'data/models/kaldi-generic-en-tdnn_sp-latest'
WAVFILE     = 'data/dw961.wav'

kaldi_model = KaldiNNet3OnlineModel (MODELDIR)
decoder     = KaldiNNet3OnlineDecoder (kaldi_model)

if decoder.decode_wav_file(WAVFILE):

    s, l = decoder.get_decoded_string()

    print
    print u"*****************************************************************"
    print u"**", WAVFILE
    print u"**", s
    print u"** %s likelihood:" % MODELDIR, l
    print u"*****************************************************************"
    print

else:

    print "***ERROR: decoding of %s failed." % WAVFILE

Please check the examples directory for more example code.

Requirements

Setup Notes

Source

At the time of this writing kaldi-asr does not seem to have an official way to install it on a system.

So, for now we will rely on pkg-config to provide LIBS and CFLAGS for compilation: Create a file called kaldi-asr.pc somewhere in your PKG_CONFIG_PATH that provides this information - here is what such a file could look like (details depend on your OS environment):

kaldi_root=/opt/kaldi

Name: kaldi-asr
Description: kaldi-asr speech recognition toolkit
Version: 5.2
Requires: atlas
Libs: -L${kaldi_root}/tools/openfst/lib -L${kaldi_root}/src/lib -lkaldi-decoder -lkaldi-lat -lkaldi-fstext -lkaldi-hmm -lkaldi-feat -lkaldi-transform -lkaldi-gmm -lkaldi-tree -lkaldi-util -lkaldi-matrix -lkaldi-base -lkaldi-nnet3 -lkaldi-online2 -lkaldi-cudamatrix -lkaldi-ivector -lfst
Cflags: -I${kaldi_root}/src  -I${kaldi_root}/tools/openfst/include

make sure kaldi_root points to wherever your kaldi checkout lives in your filesystem.

ATLAS

You may need to install ATLAS headers even if you didn't need them to compile Kaldi.

$ sudo apt install libatlas-dev

License

My own code is Apache licensed unless otherwise noted in the script's copyright headers.

Some scripts and files are based on works of others, in those cases it is my intention to keep the original license intact. Please make sure to check the copyright headers inside for more information.

Author

Guenter Bartsch [email protected]
Kaldi 5.1 adaptation contributed by mariasmo https://github.com/mariasmo
Kaldi GMM model support contributed by David Zurow https://github.com/daanzu
Python > 3.5 support contributed by Jakob Kruse https://github.com/jakob1111996

py-kaldi-asr's People

Contributors

daanzu avatar gooofy avatar jakobkruse1 avatar mariasmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py-kaldi-asr's Issues

how to run decoding on chain model built by myself

Guenter,
Thanks for your work, I successfully compiled and tested your code. And also I can do decoding using your pre-trained model (kaldi-generic-en-tdnn_f-r20190609) now. Great work!

Meanwhile, I am learning Kaldi, and almost finished my first model building using one of Mandarin recipes (aishell). And I just want to know whether it is possible to run decoding task using your code with my own model?

My model is a chain model which was built following the standard recipe (kaldi/egs/aishell/s5/local/chain/run_tdnn.sh)

One possible difficulty I realized is how to collect all the needed data files into model directory, please advice if there is a instruction document on which files are needed and the corresponding source directory of kaldi. By reading your code, seems just collect all the files mentioned in the following code:

    ****cdef unicode mfcc_config           = u'%s/conf/mfcc_hires.conf'                  % self.modeldir
    cdef unicode word_symbol_table     = u'%s/%s/graph/words.txt'                    % (self.modeldir, self.model)
    cdef unicode model_in_filename     = u'%s/%s/final.mdl'                          % (self.modeldir, self.model)
    cdef unicode splice_conf_filename  = u'%s/ivectors_test_hires/conf/splice.conf'  % self.modeldir
    cdef unicode fst_in_str            = u'%s/%s/graph/HCLG.fst'                     % (self.modeldir, self.model)
    cdef unicode align_lex_filename    = u'%s/%s/graph/phones/align_lexicon.int'     % (self.modeldir, self.model)**

    **self.ie_conf_f.write((u"--cmvn-config=%s/conf/online_cmvn.conf\n" % self.modeldir).encode('utf8'))**
    self.ie_conf_f.write((u"--ivector-period=%d\n" % online_ivector_period).encode('utf8'))
    **self.ie_conf_f.write((u"--splice-config=%s\n" % splice_conf_filename).encode('utf8'))**
    **self.ie_conf_f.write((u"--lda-matrix=%s/extractor/final.mat\n" % self.modeldir).encode('utf8'))
    self.ie_conf_f.write((u"--global-cmvn-stats=%s/extractor/global_cmvn.stats\n" % self.modeldir).encode('utf8'))
    self.ie_conf_f.write((u"--diag-ubm=%s/extractor/final.dubm\n" % self.modeldir).encode('utf8'))**
    **self.ie_conf_f.write((u"--ivector-extractor=%s/extractor/final.ie\n" % self.modeldir).encode('utf8'))**
    self.ie_conf_f.write((u"--num-gselect=%d\n" % num_gselect).encode('utf8'))
    self.ie_conf_f.write((u"--min-post=%f\n" % min_post).encode('utf8'))
    self.ie_conf_f.write((u"--posterior-scale=%f\n" % posterior_scale).encode('utf8'))
    self.ie_conf_f.write((u"--max-remembered-frames=1000\n").encode('utf8'))
    self.ie_conf_f.write((u"--max-count=%d\n" % max_count).encode('utf8'))
    self.ie_conf_f.flush()**

Could you kindly elaborate a little about the source directory of those needed files?

Thanks!
Kelvin

Troubles with running example script "examples/nnet3_online.py"

Hello!
I successfully installed py-kaldi-asr. But when I run "examples/nnet3_online.py", I get the following error:
Traceback (most recent call last):
File "examples/nnet3_online.py", line 32, in
from kaldiasr.nnet3 import KaldiNNet3OnlineModel, KaldiNNet3OnlineDecoder
File "build/bdist.linux-x86_64/egg/kaldiasr/nnet3.py", line 7, in
File "build/bdist.linux-x86_64/egg/kaldiasr/nnet3.py", line 6, in bootstrap
ImportError: /home/kazan/.cache/Python-Eggs/py_kaldi_asr-0.2.4-py2.7-linux-x86_64.egg-tmp/kaldiasr/nnet3.so: undefined symbol: FLAGS_fst_error_fatal

Could you help me with it?

run time error

RuntimeError Traceback (most recent call last)
in
2 WAVFILE = '/home/sravani/cut12-2.wav'
3
----> 4 kaldi_model = KaldiNNet3OnlineModel (MODELDIR)
5 decoder = KaldiNNet3OnlineDecoder (kaldi_model)
6

~/anaconda3/lib/python3.8/site-packages/kaldiasr/nnet3.pyx in kaldiasr.nnet3.KaldiNNet3OnlineModel.cinit()

RuntimeError: kaldi::KaldiFatalError

Way to add new word

Hi,

I would like adding a new word, but this word doesn't exist in CMU pronounce dictionary. So I used logios lexicon tool to generate a new pronunciation dictionary. I would like to know how to add this new dictionary to the existing model? Thank you so much.

Kaldi nnet3 without ivector model

Hi,
Can I use a kaldi model that trained without ivector ?

I tried to use kaldi_decode_wav.py with this model but got:

DEBUG:root:/models/ loading model... Traceback (most recent call last): File "kaldi_decode_wav.py", line 60, in <module> kaldi_model = KaldiNNet3OnlineModel (options.modeldir, acoustic_scale=1.0, beam=7.0, frame_subsampling_factor=3) File "kaldiasr/nnet3.pyx", line 134, in kaldiasr.nnet3.KaldiNNet3OnlineModel.__cinit__ RuntimeError

/opt/kaldi/src/nnet3/nnet-common.h:28:10: fatal error: cudamatrix/cu-matrix-lib.h: No such file or directory - #include "cudamatrix/cu-matrix-lib.h"

Run under wsl.

root:~/audio/py-kaldi-asr# python setup.py install
looking for atlas library, trying pkg-config first...
looking for atlas library, pkg-config found it
looking for atlas library, trying pkg-config first...
looking for atlas library, pkg-config found it
running install
running bdist_egg
running egg_info
creating py_kaldi_asr.egg-info
writing requirements to py_kaldi_asr.egg-info/requires.txt
writing py_kaldi_asr.egg-info/PKG-INFO
writing top-level names to py_kaldi_asr.egg-info/top_level.txt
writing dependency_links to py_kaldi_asr.egg-info/dependency_links.txt
writing manifest file 'py_kaldi_asr.egg-info/SOURCES.txt'
reading manifest file 'py_kaldi_asr.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'data/gso1.wav'
writing manifest file 'py_kaldi_asr.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/kaldiasr
copying kaldiasr/__init__.py -> build/lib.linux-x86_64-2.7/kaldiasr
copying kaldiasr/gmm.pyx -> build/lib.linux-x86_64-2.7/kaldiasr
copying kaldiasr/gmm_wrappers.cpp -> build/lib.linux-x86_64-2.7/kaldiasr
copying kaldiasr/gmm_wrappers.h -> build/lib.linux-x86_64-2.7/kaldiasr
copying kaldiasr/nnet3.pyx -> build/lib.linux-x86_64-2.7/kaldiasr
copying kaldiasr/nnet3_wrappers.cpp -> build/lib.linux-x86_64-2.7/kaldiasr
copying kaldiasr/nnet3_wrappers.h -> build/lib.linux-x86_64-2.7/kaldiasr
running build_ext
cythoning kaldiasr/nnet3.pyx to kaldiasr/nnet3.cpp
building 'kaldiasr.nnet3' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/kaldiasr
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-PPrPZj/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/x86_64-linux-gnu -I/opt/kaldi/src -I/opt/kaldi/tools/openfst/include -I/usr/include/x86_64-linux-gnu -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c kaldiasr/nnet3.cpp -o build/temp.linux-x86_64-2.7/kaldiasr/nnet3.o -Wall -pthread -std=c++11 -DKALDI_DOUBLEPRECISION=0 -Wno-sign-compare -Wno-unused-local-typedefs -Winit-self -DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_ATLAS -g
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1809:0,
                 from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                 from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from kaldiasr/nnet3.cpp:505:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \
  ^~~~~~~
In file included from /opt/kaldi/src/nnet3/nnet-component-itf.h:26:0,
                 from /opt/kaldi/src/nnet3/nnet-compile.h:23,
                 from /opt/kaldi/src/nnet3/nnet-optimize.h:24,
                 from /opt/kaldi/src/nnet3/nnet-am-decodable-simple.h:28,
                 from kaldiasr/nnet3_wrappers.h:28,
                 from kaldiasr/nnet3.cpp:507:
/opt/kaldi/src/nnet3/nnet-common.h:28:10: fatal error: cudamatrix/cu-matrix-lib.h: No such file or directory
 #include "cudamatrix/cu-matrix-lib.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

RunTime error when performing WAV decode

When running the example script, it performs perfectly on the supplied demo1.wav, demo2.wav etc.

However, when I supply my own .wav files, I get the following error:

Traceback (most recent call last):
  File "asr_test.py", line 13, in <module>
    if decoder.decode_wav_file(WAVFILE):
  File "kaldiasr/nnet3.pyx", line 207, in kaldiasr.nnet3.KaldiNNet3OnlineDecoder.decode_wav_file (kaldiasr/nnet3.cpp:4726)
  File "kaldiasr/nnet3.pyx", line 170, in kaldiasr.nnet3.KaldiNNet3OnlineDecoder.decode (kaldiasr/nnet3.cpp:3968)
RuntimeError

RuntimeError isn't particularly descriptive - is there a way I can more effectively get to the bottom of what's going on?
Thanks.

atlas issue [again]

hi,

i have experienced the atlas issue also.
It is similar to Setup error:cannot find -lsatlas #23 and I think the readme must be updated.

Option 1
add pkg-config for atlas - most probably for various systems (in my case I use Ubuntu)

Option 2
skip the atlas in requirements in pkg-config for kaldi-asr.pc

thx,
r

Setup error:cannot find -lsatlas

Setup of py-kaldi-asr fails on /usr/bin/ld: cannot find -lsatlas
I've tried both 0.4.1 and 0.5.0 (after adding README.md manually) but both unsuccessfully.

t-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/kaldiasr/nnet3.o build/temp.linux-x86_64-3.6/kaldiasr/nnet3_wrappers.o -L/usr/lib/atlas-base -L/home/user1/Kaldi/kaldi-asr/kaldi/tools/openfst/lib -L/home/user1/Kaldi/kaldi-asr/kaldi/src/lib -L/usr/lib/atlas-base -lsatlas -lkaldi-decoder -lkaldi-lat -lkaldi-fstext -lkaldi-hmm -lkaldi-feat -lkaldi-transform -lkaldi-gmm -lkaldi-tree -lkaldi-util -lkaldi-matrix -lkaldi-base -lkaldi-nnet3 -lkaldi-online2 -lkaldi-cudamatrix -lkaldi-ivector -lfst -lsatlas -o build/lib.linux-x86_64-3.6/kaldiasr/nnet3.cpython-36m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lsatlas
/usr/bin/ld: cannot find -lsatlas
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1

kaldi-asr.pc and atlas.pc both configured correctly.
All dependencies are installed either (Cython)

Any suggestions?

why does it compile "-c kaldiasr/nnet3.c" instead of "-c kaldiasr/nnet3.cpp"

When I was trying to compile py-kaldi-asr on ubuntu16.04, I got following message:

make all
python setup.py build_ext --inplace
looking for atlas library, trying pkg-config first...
looking for atlas library, pkg-config found it
looking for atlas library, trying pkg-config first...
looking for atlas library, pkg-config found it
running build_ext
building 'kaldiasr.nnet3' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/atlas -I/usr/local/kaldi/kaldi-trunk/src -I/usr/local/kaldi/kaldi-trunk/tools/openfst/include -I/usr/include/atlas -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c kaldiasr/nnet3.c -o build/temp.linux-x86_64-2.7/kaldiasr/nnet3.o -Wall -pthread -std=c++11 -DKALDI_DOUBLEPRECISION=0 -Wno-sign-compare -Wno-unused-local-typedefs -Winit-self -DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_OPENBLAS -g -Wl,-no-as-needed
x86_64-linux-gnu-gcc: error: kaldiasr/nnet3.c: No such file or directory
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Makefile:12: recipe for target 'kaldiasr/nnet3.so' failed
make: *** [kaldiasr/nnet3.so] Error 1

Why is it so strange to compile "nnet3.c"?

Unable to run Example Application

Hi,
Im running ubuntu 18.04, with python2.7.17 and have setup Kaldi as per the installation instruction available in their website. When I try to run your example application, python kaldi_decode_wav.py -v demo?.wav, I'm getting the below error. Kindly help to resolve this.

Traceback (most recent call last):
  File "kaldi_decode_wav.py", line 36, in <module>
    from kaldiasr.nnet3 import KaldiNNet3OnlineModel, KaldiNNet3OnlineDecoder
ImportError: No module named kaldiasr.nnet3

Cannot run properly

Hi,

I tried to run your code. I succeed to get nnet3.so file. Then, I tried to run examples/nnet3_online.py but I get the following error:

Traceback (most recent call last):
File "examples/nnet3_online.py", line 32, in
from kaldisimple.nnet3 import KaldiNNet3OnlineDecoder
ImportError: No module named kaldisimple.nnet3

Do you have any idea about this?

Cannot find Kaldi libs for installation

Hi, upon installing, I get the following errors:
/usr/bin/ld: cannot find -lkaldi-decoder
/usr/bin/ld: cannot find -lkaldi-lat
/usr/bin/ld: cannot find -lkaldi-fstext
/usr/bin/ld: cannot find -lkaldi-hmm
/usr/bin/ld: cannot find -lkaldi-feat
/usr/bin/ld: cannot find -lkaldi-transform
/usr/bin/ld: cannot find -lkaldi-gmm
/usr/bin/ld: cannot find -lkaldi-tree
/usr/bin/ld: cannot find -lkaldi-util
/usr/bin/ld: cannot find -lkaldi-matrix
/usr/bin/ld: cannot find -lkaldi-base
/usr/bin/ld: cannot find -lkaldi-nnet3
/usr/bin/ld: cannot find -lkaldi-online2
/usr/bin/ld: cannot find -lkaldi-cudamatrix
/usr/bin/ld: cannot find -lkaldi-ivector
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1

I checked kaldi/src/ and indeed there is no lib/ directory over there. Where can I find the necessary libs? I have already installed kaldi.

Cannot find OnlineNnet3DecodingConfig in the code

When compiling I get this error

In file included from kaldisimple/nnet3.cpp:456:
kaldisimple/nnet3_wrappers.h:64:9: error: unknown type name
      'OnlineNnet3DecodingConfig'
        OnlineNnet3DecodingConfig                 nnet3_decoding_config;

and a grep on both the Kaldi code and py-kaldi does not show any definition for this class, do you know where this code should be defined?

run time error

in
6 if decoder.decode_wav_file(WAVFILE):
7
----> 8 s, l = decoder.get_decoded_string()
9
10 print(u"*****************************************************************")

~/anaconda3/lib/python3.8/site-packages/kaldiasr/nnet3.pyx in kaldiasr.nnet3.KaldiNNet3OnlineDecoder.get_decoded_string()

For some files it is giving output. But for some files it is giving error like this. Audio file properties are same.

ATLAS issue [Mac OS X]

What is a quick way to get atlas installed on Max OSX?
I cloned the repo and encountered the "can't find atlas package" error while making.
I realized that apt install command doesn't work on OSX and couldn't find an equivalent package as libatlas-dev on homebrew, which leads to me following a tutorial to install ATLAS package on my MacBook.
It took me a whole day(around 8 hours) to build ATLAS, yet for some reasons it still lacks the ".so" files (e.g libatlas.so.3). I couldn't find out where I did wrong during build, and really don't want to waste another whole day building/installing atlas...

If there's any quick and clean way to get the atlas package needed to make this repo, please let me know!! Thanks so much

Error while loading nnet3 model

When running your nnet3_online.py example, I get the following error:

Traceback (most recent call last):
  File "py-kaldi-test.py", line 21, in <module>
    kaldi_model = KaldiNNet3OnlineModel (MODELDIR, model)
  File "kaldiasr/nnet3.pyx", line 52, in kaldiasr.nnet3.KaldiNNet3OnlineModel.__cinit__
  File "stringsource", line 15, in string.from_py.__pyx_convert_string_from_py_std__in_string
TypeError: expected bytes, str found```

[BUG] Memory leaks - Model

I have discovered, that memory is leaking by using the model/decoder.

Scenario

Load model, use it, unload -> the memory is released partially.

def runner_model():
    mem_usage = memory_profiler.memory_usage(-1, interval=.1, timeout=.5)
    print('> %s > mem=%s' % ('load model', max(mem_usage)))
    #
    model = KaldiNNet3OnlineModel(
        MODELDIR,
        acoustic_scale=1.0,
        beam=7.0,
        frame_subsampling_factor=3,
    )
    #
    mem_usage = memory_profiler.memory_usage(-1, interval=.1, timeout=.5)
    print('> %s > mem=%s' % ('model loaded', max(mem_usage)))
    try:
        for i in range(3):
            mem_usage = memory_profiler.memory_usage(-1, interval=.1, timeout=.5)
            print('> %s > mem=%s' % (' ---> MODEL iteration #%s' % i, max(mem_usage)))
            #
            # do something
            #
            mem_usage = memory_profiler.memory_usage(-1, interval=.1, timeout=.5)
            print('> %s > mem=%s' % (' ###> MODEL iteration #%s' % i, max(mem_usage)))
    finally:
        mem_usage = memory_profiler.memory_usage(-1, interval=.1, timeout=.5)
        print()
        print('> %s > mem=%s' % ('delete model', max(mem_usage)))
        #
        del model
        #
        mem_usage = memory_profiler.memory_usage(-1, interval=.1, timeout=.5)
        print()
        print('> %s > mem=%s' % ('model deleted', max(mem_usage)))

def task():
    mem_usage = memory_profiler.memory_usage(-1, interval=.1, timeout=.5)
    print('> %s > mem=%s' % ('start task', max(mem_usage)))
    #
    runner_model()
    #
    mem_usage = memory_profiler.memory_usage(-1, interval=.1, timeout=.5)
    print('> %s > mem=%s' % ('finish task', max(mem_usage)))

the output:

> start task > mem=45.46875
> load model > mem=45.46875
> model loaded > mem=356.10546875
>  ---> MODEL iteration #0 > mem=356.10546875
>  ###> MODEL iteration #0 > mem=356.10546875
>  ---> MODEL iteration #1 > mem=356.10546875
>  ###> MODEL iteration #1 > mem=356.10546875
>  ---> MODEL iteration #2 > mem=356.10546875
>  ###> MODEL iteration #2 > mem=356.10546875
> delete model > mem=356.10546875
> model deleted > mem=255.890625
> finish task > mem=255.890625

I see that 200MB are not released back - cf. > start task > mem=45.46875 and > finish task > mem=255.890625

[BUG] Memory leaks - Decoder in thread

Similar issue as with the model (#36).

Scenario

decoder n files in a list with

  • option A - use same decoder
decoder = KaldiNNet3OnlineDecoder(model)
try:
    for filename in [...]:
        decode(decoder, filename)
finally:
    del decoder
  • option B - create a new decoder for each file
def decode(filename):
  decoder = KaldiNNet3OnlineDecoder(model)
  try:
     ...
  finally:
    del decoder

for filename in [...]:
    decode(filename)
  • option C - when running option A and B in separate thread, the memory usage increases by ~10mb for each file, even del decoder is used. Deleting the model has not effect, since it leaving much bigger leak in the memory (see #36)

pkg-config related issue

Hi,

I'm installing py-kaldi-asr via pip on condaenv, but I'm getting this error:

Collecting py-kaldi-asr
Using cached https://files.pythonhosted.org/packages/be/c9/b25dd5d9d5621a8e3327b931e22e69ee256c50767c3646b087c9f05047fd/py-kaldi-asr-0.3.0.tar.gz
Complete output from command python setup.py egg_info:
Package kaldi-asr was not found in the pkg-config search path.
Perhaps you should add the directory containing `kaldi-asr.pc'
to the PKG_CONFIG_PATH environment variable
No package 'kaldi-asr' found
looking for atlas library, trying pkg-config first...
looking for atlas library, pkg-config found it
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-2tNyTW/py-kaldi-asr/setup.py", line 99, in
find_dependencies()),
File "/tmp/pip-build-2tNyTW/py-kaldi-asr/setup.py", line 72, in find_dependencies
raise Exception("
* failed to find pkgconfig for kaldi-asr")
Exception: *** failed to find pkgconfig for kaldi-asr

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-2tNyTW/py-kaldi-asr/

I had encountered a similar issue with the .pc file for Atlas, but managed a workaround(as the file was in a different dir) but I'm completely lost at this, mostly because I just got swamped with some other work.

System:
Ubuntu 18.04 on Oracle Virtualbox (Host Windows 8)
Python 2.7 (Anaconda) (but I'm using "pip" for this and not "conda")

Thanks!(This is my first git issue ever)

unnecessary comment: What's the deal with pkg-config anyway?

CUDA Support

Is it possible to enable CUDA acceleration for decoding a wav file with KaldiNNet3OnlineDecoder?

Frame Shift

if (!CompactLatticeToWordAlignment(best_path_aligned, &word_idxs, &times, &lengths)) {

When using kaldi directly I've been able to pass --frame-shift=0.03 for a chained model to get the correct timestamps for word alignment. Right now it looks like calling get_word_alignment returns arrays of integers which can just be divided by 100 to get the same value as I would get from calling nbest-to-ctm directly. I'm not seeing how I can pass in frame shift value though.

Any thoughts?

setup.py: Issue with numpy dependency

The file setup.py imports numpy at the top, but this will fail if numpy isn't installed on the system yet. So a simple pip install py-kaldi-asr is not possible on a newly set up Python environment. But adding numpy to install_requires won't help either, because pip runs setup.py to find out the package's requirements.

There seem to be solutions, but they're not clean (see How to Bootstrap numpy installation in setup.py
).

Maybe you can mark this issue as low priority.

Input feature dimension mismatch

hi guys
when I trying to decode the chain model, there is a error and how fix it ?
ERROR ([5.4.155~1399-fdd8]:DecodableNnetLoopedOnlineBase():decodable-online-looped.cc:45) Input feature dimension mismatch: got 40 but network expects 43

RuntimeError

When i ran chain_online.py, getting RuntimeError.
data/e2e_tdnnf loading model...
Traceback (most recent call last):
File "chain_online.py", line 40, in
kaldi_model = KaldiNNet3OnlineModel (MODELDIR, MODEL)
File "kaldiasr/nnet3.pyx", line 134, in kaldiasr.nnet3.KaldiNNet3OnlineModel.cinit
self.model_wrapper = new NNet3OnlineModelWrapper(beam,
RuntimeError: kaldi::KaldiFatalError

Can anyone help me out in knowing why this error came and how to fix it.

linking issue when experimenting

new to this python binding, but i followed the instructions and nnet3.so compiled successfully with kaldi 5.0.
However, when testing, import kaldisimple.nnet3, it shows import error, undefined symbol _ZTVN3fst11SymbolTableE, i already put the tools/openfst/lib into the LD_LIBRARY_PATH, but the issue is still there? anything i am missing? many thanks

Is there any script that can output the resulting lattice?

The reason for asking is that the metric of lattice oracle accuracy (i.e. best accuracy achieved by any path in the lattice) is for some use cases much more useful than word error rate (WER) or sentence error rate (SER). Such use cases are: rescoring lattice with dialog history, rescoring lattice with parsing results etc.

PyPi package: How to get source for specific version?

It's very convenient to be able to install py-kaldi-asr with pip install py-kaldi-asr. But how can I get the source code for a specific version of py-kaldi-asr? It would be nice if there'd be releases under https://github.com/gooofy/py-kaldi-asr/releases so that the version numbers correspond to the versions on PyPi.

If you don't want to release on GitHub, it would be nice if you'd create tags with the corresponding version numbers as names.

make error

g++ -pthread -shared -L/root/anaconda3/envs/pykaldienv/lib -B /root/anaconda3/envs/pykaldienv/compiler_compat -Wl,-rpath=/root/anaconda3/envs/pykaldienv/lib,--no-as-needed build/temp.linux-x86_64-3.5/kaldiasr/nnet3.o build/temp.linux-x86_64-3.5/kaldiasr/nnet3_wrappers.o -L/usr/lib64/atlas/ -L/data/app/lilong/kaldi//tools/openfst/lib -L/data/app/lilong/kaldi//src/lib -L/usr/lib64/atlas/ -lsatlas -lkaldi-decoder -lkaldi-lat -lkaldi-fstext -lkaldi-hmm -lkaldi-feat -lkaldi-transform -lkaldi-gmm -lkaldi-tree -lkaldi-util -lkaldi-matrix -lkaldi-base -lkaldi-nnet3 -lkaldi-online2 -lkaldi-cudamatrix -lkaldi-ivector -lfst -lsatlas -o /data/app/lilong/py-kaldi-asr/kaldiasr/nnet3.cpython-35m-x86_64-linux-gnu.so
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lsatlas
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-decoder
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-lat
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-fstext
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-hmm
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-feat
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-transform
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-gmm
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-tree
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-util
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-matrix
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-base
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-nnet3
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-online2
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-cudamatrix
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lkaldi-ivector
/root/anaconda3/envs/pykaldienv/compiler_compat/ld: cannot find -lsatlas
collect2: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1
make: *** [kaldiasr/nnet3.so] Error 1

There are no kaldi-*.so files in kaldi root. How to complie. Who can help me!

fst related warnings and runtime errors

I have followed all the rules and successfully did make without any error but i got a few warnings

prajwalrao@prajwal-PC:~/Downloads/gnani.ai/kaldi/kaldi/py-kaldi-asr-master$ make -j 8
python setup.py build_ext --inplace
looking for atlas library, trying pkg-config first...
looking for atlas library, pkg-config found it
running build_ext
cythoning kaldiasr/nnet3.pyx to kaldiasr/nnet3.cpp
warning: kaldiasr/nnet3.pyx:140:64: local variable 'likelihood' referenced before assignment
warning: kaldiasr/nnet3.pyx:141:31: local variable 'likelihood' referenced before assignment
building 'kaldiasr.nnet3' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/kaldiasr
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-lMBuS3/python2.7-2.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/atlas/ -I/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src -I/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include -I/usr/include/atlas/ -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c kaldiasr/nnet3.cpp -o build/temp.linux-x86_64-2.7/kaldiasr/nnet3.o -Wall -pthread -std=c++11 -DKALDI_DOUBLEPRECISION=0 -Wno-sign-compare -Wno-unused-local-typedefs -Winit-self -DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_ATLAS -g
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1809:0,
                 from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                 from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from kaldiasr/nnet3.cpp:545:
/usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \
  ^~~~~~~
In file included from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include/fst/fstlib.h:123:0,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-lib.h:22,
                 from kaldiasr/nnet3_wrappers.h:27,
                 from kaldiasr/nnet3.cpp:547:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include/fst/string.h:117:54: warning: ‘TokenType’ is deprecated: Use fst::StringTokenType [-Wdeprecated-declarations]
                           bool allow_negative = false)
                                                      ^
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include/fst/string.h:107:55: note: declared here
   enum OPENFST_DEPRECATED("Use fst::StringTokenType") TokenType {
                                                       ^~~~~~~~~
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include/fst/string.h:207:59: warning: ‘TokenType’ is deprecated: Use fst::StringTokenType [-Wdeprecated-declarations]
                          const SymbolTable *syms = nullptr)
                                                           ^
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include/fst/string.h:199:55: note: declared here
   enum OPENFST_DEPRECATED("Use fst::StringTokenType") TokenType {
                                                       ^~~~~~~~~
In file included from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/pre-determinize.h:94:0,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:29,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils.h:427,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/context-fst-inl.h:23,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/context-fst.h:476,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-lib.h:23,
                 from kaldiasr/nnet3_wrappers.h:27,
                 from kaldiasr/nnet3.cpp:547:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/pre-determinize-inl.h: In instantiation of ‘void fst::PreDeterminize(fst::MutableFst<Arc>*, typename Arc::Label, std::vector<B>*) [with Arc = fst::ArcTpl<fst::LogWeightTpl<float> >; Int = int; typename Arc::Label = int]’:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:348:17:   required from ‘void fst::SafeDeterminizeWrapper(fst::MutableFst<Arc>*, fst::MutableFst<Arc>*, float) [with Arc = fst::ArcTpl<fst::LogWeightTpl<float> >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:412:51:   required from here
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/pre-determinize-inl.h:451:16: warning: unused variable ‘inserted’ [-Wunused-variable]
           bool inserted = (arc_hash[arc.ilabel].insert(this_pair)).second;
                ^~~~~~~~
In file included from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star.h:117:0,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils.h:31,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/context-fst-inl.h:23,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/context-fst.h:476,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-lib.h:23,
                 from kaldiasr/nnet3_wrappers.h:27,
                 from kaldiasr/nnet3.cpp:547:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h: In instantiation of ‘fst::DeterminizerStar<F>::OutputStateId fst::DeterminizerStar<F>::SubsetToStateId(const std::vector<fst::DeterminizerStar<F>::Element>&) [with F = fst::VectorFst<fst::ArcTpl<fst::LogWeightTpl<float> > >; fst::DeterminizerStar<F>::OutputStateId = int]’:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:200:45:   required from ‘void fst::DeterminizerStar<F>::Determinize(bool*) [with F = fst::VectorFst<fst::ArcTpl<fst::LogWeightTpl<float> > >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:631:3:   required from ‘bool fst::DeterminizeStar(F&, fst::MutableFst<typename Impl::Arc>*, float, bool*, int, bool) [with F = fst::VectorFst<fst::ArcTpl<fst::LogWeightTpl<float> > >; typename Impl::Arc = fst::ArcTpl<fst::LogWeightTpl<float> >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:381:70:   required from here
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:561:12: warning: unused variable ‘ans’ [-Wunused-variable]
       bool ans = hash_.insert(std::pair<const vector<Element>*,
            ^~~
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h: In instantiation of ‘fst::DeterminizerStar<F>::OutputStateId fst::DeterminizerStar<F>::SubsetToStateId(const std::vector<fst::DeterminizerStar<F>::Element>&) [with F = fst::MutableFst<fst::ArcTpl<fst::LogWeightTpl<float> > >; fst::DeterminizerStar<F>::OutputStateId = int]’:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:200:45:   required from ‘void fst::DeterminizerStar<F>::Determinize(bool*) [with F = fst::MutableFst<fst::ArcTpl<fst::LogWeightTpl<float> > >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:631:3:   required from ‘bool fst::DeterminizeStar(F&, fst::MutableFst<typename Impl::Arc>*, float, bool*, int, bool) [with F = fst::MutableFst<fst::ArcTpl<fst::LogWeightTpl<float> > >; typename Impl::Arc = fst::ArcTpl<fst::LogWeightTpl<float> >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:351:18:   required from ‘void fst::SafeDeterminizeWrapper(fst::MutableFst<Arc>*, fst::MutableFst<Arc>*, float) [with Arc = fst::ArcTpl<fst::LogWeightTpl<float> >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:412:51:   required from here
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:561:12: warning: unused variable ‘ans’ [-Wunused-variable]
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-lMBuS3/python2.7-2.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/atlas/ -I/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src -I/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include -I/usr/include/atlas/ -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c kaldiasr/nnet3_wrappers.cpp -o build/temp.linux-x86_64-2.7/kaldiasr/nnet3_wrappers.o -Wall -pthread -std=c++11 -DKALDI_DOUBLEPRECISION=0 -Wno-sign-compare -Wno-unused-local-typedefs -Winit-self -DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_ATLAS -g
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include/fst/fstlib.h:123:0,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-lib.h:22,
                 from kaldiasr/nnet3_wrappers.h:27,
                 from kaldiasr/nnet3_wrappers.cpp:25:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include/fst/string.h:117:54: warning: ‘TokenType’ is deprecated: Use fst::StringTokenType [-Wdeprecated-declarations]
                           bool allow_negative = false)
                                                      ^
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include/fst/string.h:107:55: note: declared here
   enum OPENFST_DEPRECATED("Use fst::StringTokenType") TokenType {
                                                       ^~~~~~~~~
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include/fst/string.h:207:59: warning: ‘TokenType’ is deprecated: Use fst::StringTokenType [-Wdeprecated-declarations]
                          const SymbolTable *syms = nullptr)
                                                           ^
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/include/fst/string.h:199:55: note: declared here
   enum OPENFST_DEPRECATED("Use fst::StringTokenType") TokenType {
                                                       ^~~~~~~~~
In file included from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/pre-determinize.h:94:0,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:29,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils.h:427,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/context-fst-inl.h:23,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/context-fst.h:476,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-lib.h:23,
                 from kaldiasr/nnet3_wrappers.h:27,
                 from kaldiasr/nnet3_wrappers.cpp:25:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/pre-determinize-inl.h: In instantiation of ‘void fst::PreDeterminize(fst::MutableFst<Arc>*, typename Arc::Label, std::vector<B>*) [with Arc = fst::ArcTpl<fst::LogWeightTpl<float> >; Int = int; typename Arc::Label = int]’:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:348:17:   required from ‘void fst::SafeDeterminizeWrapper(fst::MutableFst<Arc>*, fst::MutableFst<Arc>*, float) [with Arc = fst::ArcTpl<fst::LogWeightTpl<float> >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:412:51:   required from here
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/pre-determinize-inl.h:451:16: warning: unused variable ‘inserted’ [-Wunused-variable]
           bool inserted = (arc_hash[arc.ilabel].insert(this_pair)).second;
                ^~~~~~~~
In file included from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star.h:117:0,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils.h:31,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/context-fst-inl.h:23,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/context-fst.h:476,
                 from /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-lib.h:23,
                 from kaldiasr/nnet3_wrappers.h:27,
                 from kaldiasr/nnet3_wrappers.cpp:25:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h: In instantiation of ‘fst::DeterminizerStar<F>::OutputStateId fst::DeterminizerStar<F>::SubsetToStateId(const std::vector<fst::DeterminizerStar<F>::Element>&) [with F = fst::VectorFst<fst::ArcTpl<fst::LogWeightTpl<float> > >; fst::DeterminizerStar<F>::OutputStateId = int]’:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:200:45:   required from ‘void fst::DeterminizerStar<F>::Determinize(bool*) [with F = fst::VectorFst<fst::ArcTpl<fst::LogWeightTpl<float> > >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:631:3:   required from ‘bool fst::DeterminizeStar(F&, fst::MutableFst<typename Impl::Arc>*, float, bool*, int, bool) [with F = fst::VectorFst<fst::ArcTpl<fst::LogWeightTpl<float> > >; typename Impl::Arc = fst::ArcTpl<fst::LogWeightTpl<float> >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:381:70:   required from here
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:561:12: warning: unused variable ‘ans’ [-Wunused-variable]
       bool ans = hash_.insert(std::pair<const vector<Element>*,
            ^~~
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h: In instantiation of ‘fst::DeterminizerStar<F>::OutputStateId fst::DeterminizerStar<F>::SubsetToStateId(const std::vector<fst::DeterminizerStar<F>::Element>&) [with F = fst::MutableFst<fst::ArcTpl<fst::LogWeightTpl<float> > >; fst::DeterminizerStar<F>::OutputStateId = int]’:
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:200:45:   required from ‘void fst::DeterminizerStar<F>::Determinize(bool*) [with F = fst::MutableFst<fst::ArcTpl<fst::LogWeightTpl<float> > >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:631:3:   required from ‘bool fst::DeterminizeStar(F&, fst::MutableFst<typename Impl::Arc>*, float, bool*, int, bool) [with F = fst::MutableFst<fst::ArcTpl<fst::LogWeightTpl<float> > >; typename Impl::Arc = fst::ArcTpl<fst::LogWeightTpl<float> >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:351:18:   required from ‘void fst::SafeDeterminizeWrapper(fst::MutableFst<Arc>*, fst::MutableFst<Arc>*, float) [with Arc = fst::ArcTpl<fst::LogWeightTpl<float> >]’
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/fstext-utils-inl.h:412:51:   required from here
/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/fstext/determinize-star-inl.h:561:12: warning: unused variable ‘ans’ [-Wunused-variable]
c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-lMBuS3/python2.7-2.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-lMBuS3/python2.7-2.7.12=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/kaldiasr/nnet3.o build/temp.linux-x86_64-2.7/kaldiasr/nnet3_wrappers.o -L/usr/lib/atlas-base -L/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/src/lib -L/home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/kaldi/tools/openfst/lib -L/usr/lib/atlas-base -latlas -lfst -lkaldi-decoder -lkaldi-lat -lkaldi-fstext -lkaldi-hmm -lkaldi-feat -lkaldi-transform -lkaldi-gmm -lkaldi-tree -lkaldi-util -lkaldi-matrix -lkaldi-base -lkaldi-nnet3 -lkaldi-online2 -lkaldi-cudamatrix -lkaldi-ivector -latlas -o /home/prajwalrao/Downloads/gnani.ai/kaldi/kaldi/py-kaldi-asr-master/kaldiasr/nnet3.so

If this is an issue please do tell me where I am going wrong, because when I run an example file line chain_online.py I get this,

prajwalrao@prajwal-PC:~/Downloads/gnani.ai/kaldi/kaldi/py-kaldi-asr-master$ python chain_online.py 
tdnn_44k loading model...
Traceback (most recent call last):
  File "chain_online.py", line 43, in <module>
    kaldi_model = KaldiNNet3OnlineModel (MODELDIR, model, acoustic_scale=1.0, beam=7.0, frame_subsampling_factor=3)
  File "kaldiasr/nnet3.pyx", line 100, in kaldiasr.nnet3.KaldiNNet3OnlineModel.__cinit__
    self.model_wrapper = new NNet3OnlineModelWrapper(beam,
RuntimeError

configuration problem

the setup.py document I can not function and I find the package kaldi-arc.pc that it is unrelated to the nnet3.cpp

undefined symbol [unsolved]

On trying to import wrappers for a model and a decoder executing "from kaldiasr.nnet3 import KaldiNNet3OnlineModel, KaldiNNet3OnlineDecoder" i get

site-packages/kaldiasr/nnet3.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZTVN3fst11SymbolTableE

What must it be? Everything has been installed properly. Could you please specify what is going wrong with the package?

Not able to run the example on Ubuntu 16.04

ImportError: libkaldi-decoder.so: cannot open shared object file: No such file or directory.

Can you share simple steps to do on ubuntu 16.04 && g++ 5.4.0 to run the basic demo?

Symbol lookup error

Error: symbol lookup error: /opt/intel/mkl/lib/intel64/libmkl_vml_avx2.so: undefined symbol: mkl_serv_getenv
Script: examples/chain_online.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.