PABannier / bark.cpp

Suno AI's Bark model in C/C++ for fast text-to-speech
MIT License
630 stars 48 forks source link

cmake: fix server example building on MSYS2 environments (Windows) #152

Closed przemoc closed 2 months ago

przemoc commented 2 months ago

Winsock (ws2_32) library is needed to build bark.cpp on MSYS2 environments.

Otherwise you'll see errors like undefined reference to '__imp_WSACleanup', etc.

przemoc commented 2 months ago

Building works fine with this change.

przemoc@NUC11PHKi7C002 UCRT64 /d/git/github.com/PABannier/bark.cpp
$ cmake -B build && cmake --build build -j --config Release
-- Building for: Ninja
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/ucrt64/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/ucrt64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at encodec.cpp/ggml/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- CMAKE_SYSTEM_PROCESSOR: AMD64
-- x86 detected
-- Configuring done (7.5s)
-- Generating done (0.0s)
-- Build files have been written to: D:/git/github.com/PABannier/bark.cpp/build

[1/16] Building C object encodec.cpp/ggml/src/CMakeFiles/ggml.dir/ggml-backend.c.obj
[2/16] Building C object encodec.cpp/ggml/src/CMakeFiles/ggml.dir/ggml-alloc.c.obj
[3/16] Building CXX object examples/main/CMakeFiles/main.dir/main.cpp.obj
[4/16] Building CXX object examples/quantize/CMakeFiles/quantize.dir/main.cpp.obj
[5/16] Building CXX object encodec.cpp/CMakeFiles/encodec.dir/encodec.cpp.obj
D:/git/github.com/PABannier/bark.cpp/encodec.cpp/encodec.cpp:265:22: warning: multi-character character constant [-Wmultichar]
  265 |         if (magic != ENCODEC_FILE_MAGIC) {
      |                      ^~~~~~~~~~~~~~~~~~
[6/16] Building CXX object examples/CMakeFiles/common.dir/common.cpp.obj
[7/16] Linking CXX static library examples\libcommon.a
[8/16] Building CXX object CMakeFiles/bark.dir/bark.cpp.obj
[9/16] Building C object encodec.cpp/ggml/src/CMakeFiles/ggml.dir/ggml.c.obj
[10/16] Linking C static library encodec.cpp\ggml\src\libggml.a
[11/16] Linking CXX static library encodec.cpp\libencodec.a
[12/16] Linking CXX static library libbark.a
[13/16] Linking CXX executable examples\main\main.exe
[14/16] Linking CXX executable examples\quantize\quantize.exe
[15/16] Building CXX object examples/server/CMakeFiles/server.dir/server.cpp.obj
[16/16] Linking CXX executable examples\server\server.exe

Running works too:

przemoc@NUC11PHKi7C002 UCRT64 /d/git/github.com/PABannier/bark.cpp
$ ./build/examples/main/main -m ./models/bark-small/ggml_weights.bin -p "this is an audio generated by bark.cpp" -t 4encodec_load_model_weights: using CPU backend
encodec_load_model: n_q = 32
    __               __
   / /_  ____ ______/ /__        _________  ____
  / __ \/ __ `/ ___/ //_/       / ___/ __ \/ __ \
 / /_/ / /_/ / /  / ,<    _    / /__/ /_/ / /_/ /
/_.___/\__,_/_/  /_/|_|  (_)   \___/ .___/ .___/
                                  /_/   /_/
encodec_load_model_weights: in_channels = 1
encodec_load_model_weights: hidden_dim  = 128
encodec_load_model_weights: n_filters   = 32
encodec_load_model_weights: kernel_size = 7
encodec_load_model_weights: res_kernel  = 3
encodec_load_model_weights: n_bins      = 1024
encodec_load_model_weights: bandwidth   = 24
encodec_load_model_weights: sample_rate = 24000
encodec_load_model_weights: ftype       = 1
encodec_load_model_weights: qntvr       = 0
encodec_load_model_weights: ggml tensor size    = 320 bytes
encodec_load_model_weights: backend buffer size =  54.36 MB
encodec_load_model_weights: model size =    44.36 MB

bark_tokenize_input: prompt: 'this is an audio generated by bark.cpp'
bark_tokenize_input: number of tokens in prompt = 513, first 8 tokens: 20579 20172 20199 33733 58966 20203 28169 20222

Generating semantic tokens: [======================================>            ] (77%)

bark_print_statistics:   sample time =    65.43 ms / 600 tokens
bark_print_statistics:  predict time =  9105.84 ms / 15.18 ms per token
bark_print_statistics:    total time =  9192.73 ms

Generating coarse tokens: [==================================================>] (100%)

bark_print_statistics:   sample time =    26.88 ms / 1800 tokens
bark_print_statistics:  predict time = 89397.95 ms / 49.67 ms per token
bark_print_statistics:    total time = 89468.12 ms

Generating fine tokens: [==================================================>] (100%)encodec_eval: compute buffer size: 303.92 MB

write_wav_on_disk: Number of frames written = 288000.

bark_print_statistics:   sample time =    66.23 ms / 6144 tokens
bark_print_statistics:  predict time = 16397.62 ms / 2.67 ms per token
bark_print_statistics:    total time = 16478.04 ms

main:     load time =   298.60 ms
main:     eval time = 117106.52 ms
main:    total time = 117408.10 ms

Tested on my NUC11PHKi7C [Core i7-1165G7 @ 2.8GHz, DDR4-3200 32GB RAM, RTX 2060]. (I was not playing yet with any compilation flags to try to speed up bark.cpp, just wanted to test that it works.)

PABannier commented 2 months ago

Thanks @przemoc ! I'll add a CI for Windows as well :)

przemoc commented 2 months ago

I'll add a CI for Windows as well :)

It was my intention too, but it was late yesterday when I cloned bark.cpp, so it had to wait for today.

Done in the same way as I did it for whisper.cpp.