Closed LuggerMan closed 3 years ago
We recommend to use mingw for windows build, not visual studio.
@TarkusT , i seem to not find the CMakeLists.txt files in ur archive, maybe u could supply the "Openfst Solution" folder which contains them, too? W/out em it wont build. For your install it seems kaldi references are not found, i can supply my kaldi libs, made with VS2019 and /Mt flag. Look into kaldiwin-OpenBLAS folder, maybe it would help. https://we.tl/t-PT2DAu7lN0 (file too big for github)
@TarkusT I built only the libs specified in vosk makefile, didnt want to build all of em, the libs are there so it might be a succesfull build of the libs that vosk needs. It may be not complete though. i`ll try making all the paths in ur build ofc, results tomorrow. Also installed mingw64, will try building for win with it
u can just supply the existing libs there to ur vosk api project, i`ve stopped getting unk references for kaldi at least
From makefile:
$(KALDI_ROOT)/src/online2/kaldi-online2.a \ $(KALDI_ROOT)/src/decoder/kaldi-decoder.a \ $(KALDI_ROOT)/src/ivector/kaldi-ivector.a \ $(KALDI_ROOT)/src/gmm/kaldi-gmm.a \ $(KALDI_ROOT)/src/nnet3/kaldi-nnet3.a \ $(KALDI_ROOT)/src/tree/kaldi-tree.a \ $(KALDI_ROOT)/src/feat/kaldi-feat.a \ $(KALDI_ROOT)/src/lat/kaldi-lat.a \ $(KALDI_ROOT)/src/lm/kaldi-lm.a \ $(KALDI_ROOT)/src/hmm/kaldi-hmm.a \ $(KALDI_ROOT)/src/transform/kaldi-transform.a \ $(KALDI_ROOT)/src/cudamatrix/kaldi-cudamatrix.a \ $(KALDI_ROOT)/src/matrix/kaldi-matrix.a \ $(KALDI_ROOT)/src/fstext/kaldi-fstext.a \ $(KALDI_ROOT)/src/util/kaldi-util.a \ $(KALDI_ROOT)/src/base/kaldi-base.a \
From kaldiwin_openBLAS that i compiled:
Oohhh, i got it , some include paths were absolute. Nevertheless i would keep trying
in the link that you have sent me there were missing libs, that's why I said that your build failed.
Anyway good luck.
@TarkusT Ah ye maybe, but they can be manually built from corresponding projects. I`m a bit concerned why u still getting unk references from kaldi:: if u got the libs. Maybe check VS libs tab, if u supplied them to linker->input tab of ur project
Oi m8, just found out u tried it via GCC, consider supplying libs via -L key, not -I key like this: -lfoo -L/home/me/foo/lib
Also asking for your fst lib compiled with /Md and /Mt if you please
@TarkusT Thank u so much! For your supplied error list it clearly says: unknown reference for KALDI::, if it was in openfst you would get fst:: errors When i open ur makefile, i see u supply KALDI_LIBS to linker wrong, u should:
-L the paths to libs and -l each .lib (i`m kinda bad with makefiles, but windows differ from unix in linker options, and your error list clearly tells it cannot find kaldi libs)
So, i managed to compile, but with a flaw in my openblas, cause i just downloaded binaries for OpenBLAS, and it needs fortran. Looking for right CLAPACK BLAS lib and cleaning up the solution rn.
Hi,
Im trying to compile over windows this source too and after 2 days trying differents compliers, varibles, Makefiles, etc.. I wasn't able to compile it. From minwg-w64 console I execute the next line but the result is a compiler error in a kaldi include file:
C:\source\vosk-api-master\csharp>make
g++ -fpermissive -std=c++17 -g -O2 -DPIC -fPIC -Wno-unused-function -Ic:\source\kaldi\src -Ic:\source\openfst\src\include -I..\src -DFST_NO_DYNAMIC_LINKING -shared -o libkaldiwrap.dll vosk_wrap.c ..\src\kaldi_recognizer.cc ..\src\language_model.cc ..\src\model.cc ..\src\spk_model.cc ..\src\vosk_api.cc c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-online2.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-decoder.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-ivector.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-gmm.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-nnet3.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-tree.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-feat.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-lat.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-lm.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-hmm.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-transform.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-cudamatrix.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-matrix.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-fstext.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-util.lib c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-base.lib c:\source\kaldi..\openfst\src\lib\Release\fst.lib c:\source\kaldi..\openfst\src\extensions\ngram\Release\fstngram.lib c:\source\kaldi\tools\OpenBLAS-v0.2.14-Win64-int32\bin\libopenblas.dll
In file included from c:\source\kaldi\src/util/common-utils.h:23,
from ..\src\kaldi_recognizer.h:19,
from ..\src\kaldi_recognizer.cc:15:
c:\source\kaldi\src/util/parse-options.h: In constructor 'kaldi::ParseOptions::ParseOptions(const char)':
c:\source\kaldi\src/util/parse-options.h:42:5: error: 'setlinebuf' was not declared in this scope
setlinebuf(stderr); // buffering mode, since it's called at program start.
^~~~~~
c:\source\kaldi\src/util/parse-options.h:42:5: note: suggested alternative: 'setvbuf'
setlinebuf(stderr); // buffering mode, since it's called at program start.
^~~~~~
setvbuf
In file included from c:\source\kaldi\src/util/common-utils.h:23,
from ..\src\language_model.h:26,
from ..\src\language_model.cc:23:
c:\source\kaldi\src/util/parse-options.h: In constructor 'kaldi::ParseOptions::ParseOptions(const char)':
c:\source\kaldi\src/util/parse-options.h:42:5: error: 'setlinebuf' was not declared in this scope
setlinebuf(stderr); // buffering mode, since it's called at program start.
^~~~~~
c:\source\kaldi\src/util/parse-options.h:42:5: note: suggested alternative: 'setvbuf'
setlinebuf(stderr); // buffering mode, since it's called at program start.
^~~~~~
setvbuf
In file included from c:\source\kaldi\src/util/common-utils.h:23,
from c:\source\kaldi\src/online2/online-endpoint.h:29,
from ..\src\model.h:23,
from ..\src\model.cc:19:
c:\source\kaldi\src/util/parse-options.h: In constructor 'kaldi::ParseOptions::ParseOptions(const char)':
c:\source\kaldi\src/util/parse-options.h:42:5: error: 'setlinebuf' was not declared in this scope
setlinebuf(stderr); // buffering mode, since it's called at program start.
^~~~~~
c:\source\kaldi\src/util/parse-options.h:42:5: note: suggested alternative: 'setvbuf'
setlinebuf(stderr); // buffering mode, since it's called at program start.
^~~~~~
setvbuf
In file included from c:\source\kaldi\src/util/common-utils.h:23,
from c:\source\kaldi\src/online2/online-feature-pipeline.h:29,
from ..\src\spk_model.h:19,
from ..\src\spk_model.cc:15:
c:\source\kaldi\src/util/parse-options.h: In constructor 'kaldi::ParseOptions::ParseOptions(const char)':
c:\source\kaldi\src/util/parse-options.h:42:5: error: 'setlinebuf' was not declared in this scope
setlinebuf(stderr); // buffering mode, since it's called at program start.
^~~~~~
c:\source\kaldi\src/util/parse-options.h:42:5: note: suggested alternative: 'setvbuf'
setlinebuf(stderr); // buffering mode, since it's called at program start.
^~~~~~
setvbuf
In file included from c:\source\kaldi\src/util/common-utils.h:23,
from ..\src\kaldi_recognizer.h:19,
from ..\src\vosk_api.cc:16:
c:\source\kaldi\src/util/parse-options.h: In constructor 'kaldi::ParseOptions::ParseOptions(const char*)':
c:\source\kaldi\src/util/parse-options.h:42:5: error: 'setlinebuf' was not declared in this scope
setlinebuf(stderr); // buffering mode, since it's called at program start.
^~~~~~
c:\source\kaldi\src/util/parse-options.h:42:5: note: suggested alternative: 'setvbuf'
setlinebuf(stderr); // buffering mode, since it's called at program start.
^~~~~~
setvbuf
make: *** [libkaldiwrap.dll] Error 1
any idea to resolve this error?
Thanks.
Hi,
If i remove setlinebuf line from parse-options.h (not supported in windows as i learned today) the compile error disappears but i get a lot of this type of errors:
C:\Users\Hector\AppData\Local\Temp\ccP6oSxD.o: In function SpkModel::SpkModel(char const*)': C:\source\vosk-api-master\csharp/../src/spk_model.cc:29: undefined reference to
void kaldi::ReadKaldiObject<kaldi::Matrixkaldi::Matrix<float>::Destroy()' C:\Users\Hector\AppData\Local\Temp\ccP6oSxD.o:c:/source/kaldi/src/matrix/kaldi-vector.h:454: undefined reference to
kaldi::Vectorkaldi::Input::~Input()' C:\Users\Hector\AppData\Local\Temp\ccP6oSxD.o: In function
kaldi::nnet3::Nnet::~Nnet()':
c:/source/kaldi/src/nnet3/nnet-nnet.h:237: undefined reference to kaldi::nnet3::Nnet::Destroy()' C:\Users\Hector\AppData\Local\Temp\ccP6oSxD.o:c:/source/kaldi/src/nnet3/nnet-descriptor.h:596: undefined reference to
kaldi::nnet3::Descriptor::Destroy()'
collect2.exe: error: ld returned 1 exit status
@hjam40, your setup cannot find symbols from kaldi libs, namely kaldi-nnet3.lib and kaldi-matrix.lib. Look into this.
Hi,
I reference these libraries in the Make file: KALDI_LIBS = \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-online2.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-decoder.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-ivector.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-gmm.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-nnet3.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-tree.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-feat.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-lat.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-lm.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-hmm.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-transform.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-cudamatrix.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-matrix.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-fstext.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-util.lib \ ${KALDI_ROOT}\kaldiwin_vs2019_OPENBLAS\x64\Release\kaldi-base.lib \ ${KALDI_ROOT}..\openfst\src\lib\Release\fst.lib \ ${KALDI_ROOT}..\openfst\src\extensions\ngram\Release\fstngram.lib
and i have added this option to compile line: -L c:\source\kaldi\kaldiwin_vs2019_OPENBLAS\x64\Release
Maybe the problem is that I compiled kaldi with Visual Studio and .lib files are no compatible with mingw g++ compiler?
Thanks.
@hjam40, surely they are not cross-compatible, follow kaldi build instructions for g++, then recompile openfst and blas
Hi, Yes finally I built kaldi and openfst with MINGW64 (not easy task....) and I created libkaldiwrap.dll without errors. Now the problem is with Vosk.dll and Test.exe, I have created them with mono (mcs) and with VS (csc) but allways when i execute Test.exe I get System.DllNotFoundException. I have libkaldiwrap.dll, vosk.dll and Test.exe in the same directory but it doesn't work.... Any idea?
Thanks.
@hjam40, Ok, libopenblas.dll maybe? Did u use CLAPACK or just fortran LAPACK? if latter, it needs some flang dll-s (miniconda etc) R U doing this on c#? i`ve done c++, so maybe my knowledge is insufficient
Hi, The error rerfers to libkaldiwrap.dll: C:\source\vosk-api-master\csharp>test.exe Excepción no controlada: System.TypeInitializationException: Se produjo una excepción en el inicializador de tipo de 'Kaldi.VoskPINVOKE'. ---> System.TypeInitializationException: Se produjo una excepción en el inicializador de tipo de 'SWIGStringHelper'. ---> System.DllNotFoundException: No se puede cargar el archivo DLL 'libkaldiwrap': No se puede encontrar el módulo especificado. (Excepción de HRESULT: 0x8007007E) en Kaldi.VoskPINVOKE.SWIGStringHelper.SWIGRegisterStringCallback_Vosk(SWIGStringDelegate stringDelegate) en Kaldi.VoskPINVOKE.SWIGStringHelper..cctor() --- Fin del seguimiento de la pila de la excepción interna --- en Kaldi.VoskPINVOKE.SWIGStringHelper..ctor() en Kaldi.VoskPINVOKE..cctor() --- Fin del seguimiento de la pila de la excepción interna --- en Kaldi.VoskPINVOKE.SetLogLevel(Int32 jarg1) en Test.Main()
yes I'm using c# because I have basic knoledges from C++ (you could imagine what compile all this software and modify .h .cc has been for me). For example I have no idea whta is CLAPACK and LAPACK, these are compiler flags that I used for make library:
CFLAGS := -std=c++17 -g -O2 -DPIC -fPIC -Wno-unused-function CPPFLAGS := -Ic:\source\kaldi\src -Ic:\source\openfst\src\include -I..\src -DFST_NO_DYNAMIC_LINKING
libkaldiwrap.dll: $(VOSK_SOURCES) $(VOSK_HEADERS) $(CXX) -fpermissive $(CFLAGS) $(CPPFLAGS) -shared -o $@ $(VOSK_SOURCES) $(KALDI_LIBS)
Maybe the problem is that I'm trying to load a MINGW64 compiled dll from a dll/program compiled with mono/VS? I have kaldl, openfst and BLAS dll libraries created from VS too, but as Vosk has not a cmakelist file I don't know how to create a VS project to compile libkaldiwrap.dll from that tool (as I said in the last post I have not great c++ knoledges ). Anyone have a VS C++ project to generate the dll or knows how create it form vosk c files?
Lmao, u are me 2 months ago. For makefile - https://github.com/alphacep/vosk-api/blob/master/c/Makefile, it is easy to read, so u can make a cmake makefile from it. i am just using plain c++ and #include
We have pushed complete Docker for cross-compilation:
https://github.com/alphacep/vosk-api/blob/master/travis/Dockerfile.win
Prebuilt library is inside nuget package:
Yes, I saw it yesterday, thank you! But while the nuget package 0.3.17 works fine in my c# net core project, version 0.3.18 doesn't work, there ara compilation errors with Kaldi namespace, it doesn't exist
with Kaldi namespace, it doesn't exist
It was renamed to Vosk, see updated code sample here;
https://github.com/alphacep/vosk-api/blob/master/csharp/demo/VoskDemo.cs
K, thank you, i think this might be closed now
upload the compiled .lib file, vosk.lib
Hi, i`m recently trying to get this great lib working with VS2019 and in c code. Everything seems ok after i made a project file and added src, but i miss some libs. I was able to compile kaldiwin and get openblas binaries, but the only problem left is openfst lib, cause in VS i cant compile it with --enable-ngram-fsts and thus cant get the fst-ngram lib. Any thoughts which may propel me further? If needed i can supply my build.