Some checks failed
Bindings Tests (Go) / ubuntu-22 (push) Failing after 31s
CI (sycl) / ubuntu-22-cmake-sycl (linux/arm/v7, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl (linux/ppc64le, icx, icpx, ON) (push) Failing after 2s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/amd64, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/arm/v7, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/arm64, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/ppc64le, icx, icpx, ON) (push) Failing after 3s
CI (vad) / vad (push) Failing after 3s
CI (wasm) / emscripten (Release) (push) Failing after 4s
Bindings Tests (Ruby) / ubuntu-22 (push) Failing after 37s
CI (android) / android (push) Failing after 16s
CI (android) / android_java (push) Failing after 3s
CI (clang) / ubuntu-22-clang (linux/amd64, Debug) (push) Failing after 3s
CI (clang) / ubuntu-22-clang (linux/amd64, Release) (push) Failing after 2s
CI (clang) / ubuntu-22-clang (linux/ppc64le, Debug) (push) Failing after 3s
CI (clang) / ubuntu-22-clang (linux/ppc64le, Release) (push) Failing after 3s
CI (cpu) / ggml-ci-x64-cpu-low-perf (push) Failing after 3s
CI (cpu) / ggml-ci-x64-cpu-high-perf (push) Failing after 2s
CI (gcc) / ubuntu-22-gcc (linux/amd64, Debug) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc (linux/amd64, Release) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc (linux/ppc64le, Debug) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc (linux/ppc64le, Release) (push) Failing after 4s
CI (gcc) / ubuntu-22-gcc-arm-v7 (linux/arm/v7, Debug) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc-arm-v7 (linux/arm/v7, Release) (push) Failing after 3s
CI (quantize) / quantize (push) Failing after 3s
CI (sanitize) / ubuntu-22-gcc-sanitized (ADDRESS) (push) Failing after 3s
CI (sanitize) / ubuntu-22-gcc-sanitized (THREAD) (push) Failing after 3s
CI (sanitize) / ubuntu-22-gcc-sanitized (UNDEFINED) (push) Failing after 2s
CI (sycl) / ubuntu-22-cmake-sycl (linux/amd64, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl (linux/arm64, icx, icpx, ON) (push) Failing after 3s
Examples WASM / deploy-wasm-github-pages (push) Failing after 3s
Examples Tests / addon_node-ubuntu-22 (20.x) (push) Failing after 3s
Examples Tests / addon_node-ubuntu-22 (22.x) (push) Failing after 2s
CI (coreml) / coreml-base-en (push) Has been cancelled
CI (self-hosted) / gpu-vulkan (push) Has been cancelled
CI (self-hosted) / npu-amd-windows (push) Has been cancelled
CI (self-hosted) / gpu-vulkan-nvidia-cm2 (push) Has been cancelled
CI (clang) / ubuntu-22-clang-arm64 (Debug) (push) Has been cancelled
CI (clang) / ubuntu-22-clang-arm64 (Release) (push) Has been cancelled
CI (self-hosted) / gpu-cuda (push) Has been cancelled
CI (self-hosted) / gpu-vulkan-nvidia-cm (push) Has been cancelled
CI (cpu) / ggml-ci-arm64-cpu-low-perf (push) Has been cancelled
CI (cpu) / ggml-ci-arm64-cpu-high-perf (push) Has been cancelled
CI (cpu) / ggml-ci-arm64-cpu-high-perf-sve (push) Has been cancelled
CI (freebsd) / freeBSD-latest (push) Has been cancelled
CI (self-hosted) / gpu-metal (push) Has been cancelled
CI (gcc) / ubuntu-22-gcc-arm64 (Debug) (push) Has been cancelled
CI (gcc) / ubuntu-22-gcc-arm64 (Release) (push) Has been cancelled
CI (macOS) / macOS-latest (generic/platform=iOS) (push) Has been cancelled
CI (macOS) / macOS-latest (generic/platform=macOS) (push) Has been cancelled
CI (macOS) / macOS-latest (generic/platform=tvOS) (push) Has been cancelled
CI (self-hosted) / npu-amd-linux (push) Has been cancelled
CI (windows) / windows-msys2 (Release, clang, clang-x86_64, CLANG64) (push) Has been cancelled
CI (windows) / windows-msys2 (Release, gcc, ucrt-x86_64, UCRT64) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-cuda.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-cuda]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-intel.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-intel]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-musa.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-musa]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-vulkan.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-vulkan]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-vulkan.Dockerfile platform:linux/arm64 runs_on:ubuntu-24.04-arm tag:main-vulkan-arm64]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main.Dockerfile platform:linux/arm64 runs_on:ubuntu-24.04-arm tag:main-arm64]) (push) Has been cancelled
Mark inactive issues stale / mark-issues (push) Failing after 1s
102 lines
3.2 KiB
C++
102 lines
3.2 KiB
C++
#include "parakeet.h"
|
|
#include "common-whisper.h"
|
|
#include "parakeet-verification.h"
|
|
|
|
#include <cstdio>
|
|
#include <string>
|
|
|
|
#ifdef NDEBUG
|
|
#undef NDEBUG
|
|
#endif
|
|
#include <cassert>
|
|
|
|
struct test_state {
|
|
bool is_first = true;
|
|
std::string transcript;
|
|
};
|
|
|
|
void progress_callback(parakeet_context * ctx, parakeet_state * state, int progress, void * user_data) {
|
|
bool * called = static_cast<bool *>(user_data);
|
|
*called = true;
|
|
}
|
|
|
|
bool encoder_begin_callback(parakeet_context * ctx, parakeet_state * state, void * user_data) {
|
|
bool * called = static_cast<bool *>(user_data);
|
|
*called = true;
|
|
return true;
|
|
}
|
|
|
|
bool abort_callback(void * user_data) {
|
|
bool * called = static_cast<bool *>(user_data);
|
|
*called = true;
|
|
return false; // just continue without aborting.
|
|
}
|
|
|
|
void token_callback(parakeet_context * ctx, parakeet_state * state, const parakeet_token_data * token_data, void * user_data) {
|
|
test_state * tstate = static_cast<test_state *>(user_data);
|
|
|
|
const char * token_str = parakeet_token_to_str(ctx, token_data->id);
|
|
char text_buf[256];
|
|
parakeet_token_to_text(token_str, tstate->is_first, text_buf, sizeof(text_buf));
|
|
|
|
printf("%s", text_buf);
|
|
fflush(stdout);
|
|
|
|
tstate->transcript += text_buf;
|
|
tstate->is_first = false;
|
|
}
|
|
|
|
int main() {
|
|
std::string model_path = PARAKEET_MODEL_PATH;
|
|
std::string sample_path = SAMPLE_PATH;
|
|
|
|
std::vector<float> pcmf32;
|
|
std::vector<std::vector<float>> pcmf32s;
|
|
assert(read_audio_data(sample_path.c_str(), pcmf32, pcmf32s, false));
|
|
assert(pcmf32.size() > 0);
|
|
assert(pcmf32s.size() == 0); // no stereo vector
|
|
|
|
printf("Loading Parakeet model from: %s\n", model_path.c_str());
|
|
|
|
struct parakeet_context_params ctx_params = parakeet_context_default_params();
|
|
|
|
struct parakeet_context * pctx = parakeet_init_from_file_with_params(model_path.c_str(), ctx_params);
|
|
if (pctx == nullptr) {
|
|
fprintf(stderr, "Failed to load Parakeet model\n");
|
|
return 1;
|
|
}
|
|
printf("Successfully loaded Parakeet model\n");
|
|
|
|
struct parakeet_full_params params = parakeet_full_default_params(PARAKEET_SAMPLING_GREEDY);
|
|
test_state tstate;
|
|
params.new_token_callback = token_callback;
|
|
params.new_token_callback_user_data = &tstate;
|
|
bool progress_callback_called = false;
|
|
params.progress_callback = progress_callback;
|
|
params.progress_callback_user_data = &progress_callback_called;
|
|
bool encoder_begin_callback_called = false;
|
|
params.encoder_begin_callback = encoder_begin_callback;
|
|
params.encoder_begin_callback_user_data = &encoder_begin_callback_called;
|
|
bool abort_callback_called = false;
|
|
params.abort_callback = abort_callback;
|
|
params.abort_callback_user_data = &abort_callback_called;
|
|
|
|
int ret = parakeet_full(pctx, params, pcmf32.data(), pcmf32.size());
|
|
assert(ret == 0);
|
|
assert(progress_callback_called);
|
|
assert(encoder_begin_callback_called);
|
|
assert(abort_callback_called);
|
|
|
|
const std::string expected = read_expected_transcription(EXPECTED_TRANSCRIPTION_PATH);
|
|
const bool transcript_matches = verify_transcription(expected, tstate.transcript);
|
|
|
|
parakeet_free(pctx);
|
|
|
|
if (!transcript_matches) {
|
|
return 1;
|
|
}
|
|
|
|
printf("\nTest passed: parakeet_full succeeded!\n");
|
|
return 0;
|
|
}
|