k2-fsa / sherpa-onnx

Speech-to-text, text-to-speech, speaker recognition, and VAD using next-gen Kaldi with onnxruntime without Internet connection. Support embedded systems, Android, iOS, Raspberry Pi, RISC-V, x86_64 servers, websocket server/client, C/C++, Python, Kotlin, C#, Go, NodeJS, Java, Swift, Dart, JavaScript, Flutter, Object Pascal, Lazarus, Rust
https://k2-fsa.github.io/sherpa/onnx/index.html
Apache License 2.0
3.02k stars 343 forks source link

Installing ONNX for Windows gives error for cmake -DCMAKE_BUILD_TYPE=Release .. #176

Open Caet-pip opened 1 year ago

Caet-pip commented 1 year ago

(base) C:\Users\K2\sherpa-onnx\build>cmake -DCMAKE_BUILD_TYPE=Release .. -- Building for: NMake Makefiles CMake Error at CMakeLists.txt:2 (project): Running

'nmake' '-?'

failed with:

The system cannot find the file specified

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred! See also "C:/Users/K2/sherpa-onnx/build/CMakeFiles/CMakeOutput.log".

csukuangfj commented 1 year ago

Please install visual studio first.

mlcatinit commented 1 year ago

I am running command prompt terminal in Visual Studio Code

csukuangfj commented 1 year ago

Visual studio code is not visual studio.

Please install visual studio first. You can install a community edition, which is free.

mlcatinit commented 1 year ago

I have installed Visual Studio but still getting the same error. Should I install something specific in Visual Studio? Should I install Cmake from Visual Studio?

csukuangfj commented 1 year ago

Please activate the visual studio developer command prompt. It is different from cmd.

mlcatinit commented 1 year ago

C:\Users\Fawaz Shaik\K2\sherpa-onnx\build>cmake -DCMAKE_BUILD_TYPE=Release .. 'cmake' is not recognized as an internal or external command, operable program or batch file.

I get this as result in Visual Studio Developer Command Prompt

csukuangfj commented 1 year ago

Then, please install cmake.

The easiest way might be

pip install cmake
mlcatinit commented 1 year ago

Getting this when I try installing (base) C:\Users\Fawaz Shaik\source\repos>pip install cmake Requirement already satisfied: cmake in c:\users\fawaz shaik\appdata\roaming\python\python310\site-packages (3.26.4)

and when I try running the command:

(base) C:\Users\Fawaz Shaik\K2\sherpa-onnx\build>cmake -DCMAKE_BUILD_TYPE=Release .. CMake Error at CMakeLists.txt:2 (project): Running

'nmake' '-?'

failed with:

The system cannot find the file specified

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred! See also "C:/Users/Fawaz Shaik/K2/sherpa-onnx/build/CMakeFiles/CMakeOutput.log".

in CMakeOutput.log I get this The system is: Windows - 10.0.22621 - AMD64

csukuangfj commented 1 year ago

Could you describe how you start the terminal?

mlcatinit commented 1 year ago

In Visual Studio App from the toolbar on top

Tools > Command Line > Developer Command Prompt

csukuangfj commented 1 year ago

What is the output of

cmake --help
mlcatinit commented 1 year ago

this is the output

(base) C:\Users\Fawaz Shaik\K2\sherpa-onnx\build>cmake --help Usage

cmake [options] cmake [options] cmake [options] -S -B

Specify a source directory to (re-)generate a build system for it in the current working directory. Specify an existing build directory to re-generate its build system.

Options -S = Explicitly specify a source directory. -B = Explicitly specify a build directory. -C = Pre-load a script to populate the cache. -D [:]= = Create or update a cmake cache entry. -U = Remove matching entries from CMake cache. -G = Specify a build system generator. -T = Specify toolset name if supported by generator. -A = Specify platform name if supported by generator. --toolchain = Specify toolchain file [CMAKE_TOOLCHAIN_FILE]. --install-prefix = Specify install directory [CMAKE_INSTALL_PREFIX]. -Wdev = Enable developer warnings. -Wno-dev = Suppress developer warnings. -Werror=dev = Make developer warnings errors. -Wno-error=dev = Make developer warnings not errors. -Wdeprecated = Enable deprecation warnings. -Wno-deprecated = Suppress deprecation warnings. -Werror=deprecated = Make deprecated macro and function warnings errors. -Wno-error=deprecated = Make deprecated macro and function warnings not errors. --preset ,--preset= = Specify a configure preset. --list-presets = List available presets. -E = CMake command mode. -L[A][H] = List non-advanced cached variables. --build

= Build a CMake-generated project binary tree. --install = Install a CMake-generated project binary tree. --open = Open generated project in the associated application. -N = View mode only. -P = Process script mode. --find-package = Legacy pkg-config like mode. Do not use. --graphviz=[file] = Generate graphviz of dependencies, see CMakeGraphVizOptions.cmake for more. --system-information [file] = Dump information about this system. --log-level=<ERROR|WARNING|NOTICE|STATUS|VERBOSE|DEBUG|TRACE> = Set the verbosity of messages from CMake files. --loglevel is also accepted for backward compatibility reasons. --log-context = Prepend log messages with context, if given --debug-trycompile = Do not delete the try_compile build tree. Only useful on one try_compile at a time. --debug-output = Put cmake in a debug mode. --debug-find = Put cmake find in a debug mode. --trace = Put cmake in trace mode. --trace-expand = Put cmake in trace mode with variable expansion. --trace-format=<human|json-v1> = Set the output format of the trace. --trace-source= = Trace only this CMake file/module. Multiple options allowed. --trace-redirect= = Redirect trace output to a file instead of stderr. --warn-uninitialized = Warn about uninitialized values. --no-warn-unused-cli = Don't warn about command line options. --check-system-vars = Find problems with variable usage in system files. --profiling-format= = Output data for profiling CMake scripts. Supported formats: google-trace --profiling-output= = Select an output path for the profiling data enabled through --profiling-format. --help,-help,-usage,-h,-H,/? = Print usage information and exit. --version,-version,/V [] = Print version number and exit. --help-full [] = Print all help manuals and exit. --help-manual [] = Print one help manual and exit. --help-manual-list [] = List help manuals available and exit. --help-command [] = Print help for one command and exit. --help-command-list [] = List commands with help available and exit. --help-commands [] = Print cmake-commands manual and exit. --help-module [] = Print help for one module and exit. --help-module-list [] = List modules with help available and exit. --help-modules [] = Print cmake-modules manual and exit. --help-policy [] = Print help for one policy and exit. --help-policy-list [] = List policies with help available and exit. --help-policies [] = Print cmake-policies manual and exit. --help-property [] = Print help for one property and exit. --help-property-list [] = List properties with help available and exit. --help-properties [] = Print cmake-properties manual and exit. --help-variable var [] = Print help for one variable and exit. --help-variable-list [] = List variables with help available and exit. --help-variables [] = Print cmake-variables manual and exit.

Generators

The following generators are available on this platform (* marks default): Visual Studio 17 2022 = Generates Visual Studio 2022 project files. Use -A option to specify architecture. Visual Studio 16 2019 = Generates Visual Studio 2019 project files. Use -A option to specify architecture. Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 10 2010 [arch] = Deprecated. Generates Visual Studio 2010 project files. Optional [arch] can be "Win64" or "IA64". Visual Studio 9 2008 [arch] = Generates Visual Studio 2008 project files. Optional [arch] can be "Win64" or "IA64". Borland Makefiles = Generates Borland makefiles.

  • NMake Makefiles = Generates NMake makefiles. NMake Makefiles JOM = Generates JOM makefiles. MSYS Makefiles = Generates MSYS makefiles. MinGW Makefiles = Generates a make file for use with mingw32-make. Green Hills MULTI = Generates Green Hills MULTI files (experimental, work-in-progress). Unix Makefiles = Generates standard UNIX makefiles. Ninja = Generates build.ninja files. Ninja Multi-Config = Generates build-.ninja files. Watcom WMake = Generates Watcom WMake makefiles. CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files. CodeBlocks - NMake Makefiles = Generates CodeBlocks project files. CodeBlocks - NMake Makefiles JOM = Generates CodeBlocks project files. CodeBlocks - Ninja = Generates CodeBlocks project files. CodeBlocks - Unix Makefiles = Generates CodeBlocks project files. CodeLite - MinGW Makefiles = Generates CodeLite project files. CodeLite - NMake Makefiles = Generates CodeLite project files. CodeLite - Ninja = Generates CodeLite project files. CodeLite - Unix Makefiles = Generates CodeLite project files. Eclipse CDT4 - NMake Makefiles = Generates Eclipse CDT 4.0 project files. Eclipse CDT4 - MinGW Makefiles = Generates Eclipse CDT 4.0 project files. Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files. Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files. Kate - MinGW Makefiles = Generates Kate project files. Kate - NMake Makefiles = Generates Kate project files. Kate - Ninja = Generates Kate project files. Kate - Unix Makefiles = Generates Kate project files. Sublime Text 2 - MinGW Makefiles = Generates Sublime Text 2 project files. Sublime Text 2 - NMake Makefiles = Generates Sublime Text 2 project files. Sublime Text 2 - Ninja = Generates Sublime Text 2 project files. Sublime Text 2 - Unix Makefiles = Generates Sublime Text 2 project files.
csukuangfj commented 1 year ago

From the output of cmake --help, please do the following

  1. Delete the build directory
  2. re-create the build directory
    cd build
    cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release ..
mlcatinit commented 1 year ago

I get this output

(base) C:\Users\Fawaz Shaik\K2\sherpa-onnx>mkdir build

(base) C:\Users\Fawaz Shaik\K2\sherpa-onnx>cd build

(base) C:\Users\Fawaz Shaik\K2\sherpa-onnx\build> cmake -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release .. CMake Error at CMakeLists.txt:2 (project): Generator

Visual Studio 17 2022

could not find any instance of Visual Studio.

-- Configuring incomplete, errors occurred! See also "C:/Users/Fawaz Shaik/K2/sherpa-onnx/build/CMakeFiles/CMakeOutput.log".

this is in logs The system is: Windows - 10.0.22621 - AMD64

csukuangfj commented 1 year ago

How did you install visual studio?

The error logs show that you have not installed or configured visual studio correctly.

We have a video demo for installing sherpa-ncnn on windows. Even if it is made for sherpa-ncnn, you can also use it for sherpa-onnx. https://k2-fsa.github.io/sherpa/ncnn/install/videos.html

mlcatinit commented 1 year ago

I think after seeing the video that I had to download extra C++ stuff, I will do that and check again. Thanks!

mlcatinit commented 1 year ago

I finally got it to work, but when trying one of the streaming models from https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/zipformer-transducer-models.html#csukuangfj-sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20-bilingual-chinese-english I get this error

(base) C:\Users\Fawaz Shaik\K2\sherpa-onnx>GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 'GIT_LFS_SKIP_SMUDGE' is not recognized as an internal or external command, operable program or batch file.

csukuangfj commented 1 year ago

For windows, you can remove GIT_LFS_SKIP_SMUDGE=1 and just run

git clone https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20

We need to update the doc to mention that.

mlcatinit commented 1 year ago

Okay thanks

ls -lh doesnt work in windows

and when i Try running the command for micriphone

Real-time speech recognition from a microphone cd /path/to/sherpa-onnx

./build/bin/sherpa-onnx-microphone \ ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt \ ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.onnx \ ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx \ ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.onnx

I get a warning for pasting multuple lines of text

csukuangfj commented 1 year ago

Could you post screenshots?

mlcatinit commented 1 year ago

This is screenshot

image

csukuangfj commented 1 year ago
  1. Please remove \ and put all commands in a single line

  2. Please read the documentation carefully. For windows the doc has explicitly documented which executable to use.

mlcatinit commented 1 year ago

Hello, I read the documentation and the python code worked for me. In https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/lstm-transducer-models.html I have added ./build/bin/Release/sherpa-onnx.exe before the code ./build/bin/sherpa-onnx-microphone ./sherpa-onnx-lstm-en-2023-02-17/tokens.txt ./sherpa-onnx-lstm-en-2023-02-17/encoder-epoch-99-avg-1.onnx ./sherpa-onnx-lstm-en-2023-02-17/decoder-epoch-99-avg-1.onnx ./sherpa-onnx-lstm-en-2023-02-17/joiner-epoch-99-avg-1.onnx but it still doesnt run it gives:

(base) C:\Users\Fawaz Shaik\K2\sherpa-onnx>./build/bin/Release/sherpa-onnx.exe ./build/bin/Release/sherpa-onnx.exe ./build/bin/sherpa-onnx-microphone ./sherpa-onnx-lstm-en-2023-02-17/tokens.txt ./sherpa-onnx-lstm-en-2023-02-17/encoder-epoch-99-avg-1.onnx ./sherpa-onnx-lstm-en-2023-02-17/decoder-epoch-99-avg-1.onnx ./sherpa-onnx-lstm-en-2023-02-17/joiner-epoch-99-avg-1.onnx '.' is not recognized as an internal or external command, operable program or batch file.

csukuangfj commented 1 year ago

What is the output of

./build/bin/Release/sherpa-onnx-microphone.exe ./sherpa-onnx-lstm-en-2023-02-17/tokens.txt ./sherpa-onnx-lstm-en-2023-02-17/encoder-epoch-99-avg-1.onnx ./sherpa-onnx-lstm-en-2023-02-17/decoder-epoch-99-avg-1.onnx ./sherpa-onnx-lstm-en-2023-02-17/joiner-epoch-99-avg-1.onnx
mlcatinit commented 1 year ago

I get this output

Is it because this is in C? I am well aware of python but not experienced in C apologies

(base) C:\Users\Fawaz Shaik\K2\sherpa-onnx>./build/bin/Release/sherpa-onnx-microphone.exe ./sherpa-onnx-lstm-en-2023-02-17/tokens.txt ./sherpa-onnx-lstm-en-2023-02-17/encoder-epoch-99-avg-1.onnx ./sherpa-onnx-lstm-en-2023-02-17/decoder-epoch-99-avg-1.onnx ./sherpa-onnx-lstm-en-2023-02-17/joiner-epoch-99-avg-1.onnx '.' is not recognized as an internal or external command, operable program or batch file.

csukuangfj commented 1 year ago

Are you able to locate the generated exe?

csukuangfj commented 12 months ago

@mlcatinit

Have you managed to run it?