From dbcb245f55ba08bdcd970a1bd7946adb8851b659 Mon Sep 17 00:00:00 2001 From: Paul Zhu <35409183+vinovo@users.noreply.github.com> Date: Sun, 20 Oct 2024 00:55:43 -0700 Subject: [PATCH] maint: export function for dll in bark.h (#198) --- CMakeLists.txt | 2 ++ bark.h | 30 ++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9f7375..9db17c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ set(BARK_LIB bark) add_subdirectory(encodec.cpp) +add_definitions(-DEXPORTING_BARK) + add_library(${BARK_LIB} STATIC bark.cpp bark.h) if (BARK_BUILD_EXAMPLES) diff --git a/bark.h b/bark.h index 59303d8..e6426f8 100644 --- a/bark.h +++ b/bark.h @@ -21,6 +21,16 @@ #include "ggml-backend.h" #include "ggml.h" +#ifdef _WIN32 + #ifdef EXPORTING_BARK + #define BARK_API __declspec(dllexport) + #else + #define BARK_API __declspec(dllimport) + #endif +#else + #define BARK_API +#endif + #ifdef __cplusplus extern "C" { #endif @@ -135,7 +145,7 @@ extern "C" { * * @return bark_context_params The default parameters for a bark context. */ - struct bark_context_params bark_context_default_params(void); + BARK_API struct bark_context_params bark_context_default_params(void); /** * Loads a Bark model from the specified file path with the given parameters. @@ -145,7 +155,7 @@ extern "C" { * @param seed The seed to use for random number generation. * @return A pointer to the loaded bark model context. */ - struct bark_context *bark_load_model( + BARK_API struct bark_context *bark_load_model( const char *model_path, struct bark_context_params params, uint32_t seed); @@ -158,7 +168,7 @@ extern "C" { * @param n_threads The number of threads to use for generating the audio. * @return An integer indicating the success of the audio generation process. */ - bool bark_generate_audio( + BARK_API bool bark_generate_audio( struct bark_context *bctx, const char *text, int n_threads); @@ -169,7 +179,7 @@ extern "C" { * @param bctx The Bark context to use for generating the audio. * @return A pointer to the audio data generated by the Bark context. */ - float *bark_get_audio_data( + BARK_API float *bark_get_audio_data( struct bark_context *bctx); /** @@ -178,7 +188,7 @@ extern "C" { * @param bctx The Bark context to use for generating the audio. * @return The size of the audio data generated by the Bark context. */ - int bark_get_audio_data_size( + BARK_API int bark_get_audio_data_size( struct bark_context *bctx); /** @@ -187,7 +197,7 @@ extern "C" { * @param bctx The Bark context to use for generating the audio. * @return A struct containing the statistics of the last audio generation round. */ - int64_t bark_get_load_time( + BARK_API int64_t bark_get_load_time( struct bark_context *bctx); /** @@ -196,7 +206,7 @@ extern "C" { * @param bctx The Bark context to use for generating the audio. * @return A struct containing the statistics of the last audio generation round. */ - int64_t bark_get_eval_time( + BARK_API int64_t bark_get_eval_time( struct bark_context *bctx); /** @@ -205,7 +215,7 @@ extern "C" { * @param bctx The Bark context to use for generating the audio. * @return A struct containing the statistics of the last audio generation round. */ - void bark_reset_statistics( + BARK_API void bark_reset_statistics( struct bark_context *bctx); /** @@ -216,7 +226,7 @@ extern "C" { * @param ftype The type of the model's floating-point values. * @return True if the model was successfully quantized and saved, false otherwise. */ - bool bark_model_quantize( + BARK_API bool bark_model_quantize( const char *fname_inp, const char *fname_out, enum ggml_ftype ftype); @@ -226,7 +236,7 @@ extern "C" { * * @param bctx The bark context to free. */ - void bark_free( + BARK_API void bark_free( struct bark_context *bctx); #ifdef __cplusplus