csukuangfj / kaldifeat

Kaldi-compatible online & offline feature extraction with PyTorch, supporting CUDA, batch processing, chunk processing, and autograd - Provide C++ & Python API
https://csukuangfj.github.io/kaldifeat
Other
186 stars 35 forks source link

changes for using C++ API by other projects #60

Closed veelion closed 1 year ago

veelion commented 1 year ago

I use the C++ API in wenet runtime with FetchContent. But kaldifeat's CMakeLists.txt use CMAKE_SOURCE_DIR, which is path to wenet/runtime/libtorch, then kaldifeat couldn't find its own cmake module. so, I make two changes to make kaldifeat working fine as a dependenty project to other projects.:

  1. change it to CMAKE_CURRENT_SOURCE_DIR.
  2. add option kaldifeat_BUILD_PYMODULE, which can be set OFF by other projects. we only use C++ api, but kaldifeat default to build python module by add_subdirectory(python)

But, without these changes, kaldifeat works fine with k2, why? Because there're cmake modules in k2/cmake/ used by kaldifeat, in other words, kaldifeat use k2's cmake modules not its own.

With the 2nd change, k2 needs set kaldifeat_BUILD_PYMODULE to OFF in k2/cmake/kaldifeat.cmake. k2 needs no change.

csukuangfj commented 1 year ago

without this change, kaldifeat's pybind11.cmake conflicts with wenet(and k2)'s pybind11.cmake, so just turn it OFF

What are the error messages for that?

veelion commented 1 year ago

without this change, kaldifeat's pybind11.cmake conflicts with wenet(and k2)'s pybind11.cmake, so just turn it OFF

What are the error messages for that?

CMake Error at fc_base/kaldifeat-src/kaldifeat/python/csrc/CMakeLists.txt:2 (pybind11_add_module):
Unknown CMake command "pybind11_add_module".

wenet/runtime/libtorch only use C++ without include(pybind11). kaldifeat also did not as a dependented project:

if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)  # this is false in other projects, e.g. wenet
  include(pybind11)
endif()

but kaldifeat/kaldifeat/CMakeLists.txt : add_subdirectory(python), so got the error Unknown CMake command pybind11_add_module".

K2 has include pybind11 before include(kaldifeat), so it has no error.

csukuangfj commented 1 year ago

I see.

Thanks for your contribution!

veelion commented 1 year ago

Thank you. Would you like to make a new release, so that I can link to the new zip file in cmake.

csukuangfj commented 1 year ago

Thank you. Would you like to make a new release, so that I can link to the new zip file in cmake.

Please see https://github.com/csukuangfj/kaldifeat/releases/tag/v1.21

veelion commented 1 year ago

Thanks.