Bắt đầu — Linux

speech-core bao gồm API C cho các nền tảng Linux nhúng (ô tô, Yocto, thiết bị biên) trong examples/linux/. Cùng engine pipeline C++ chạy trên Android, hướng tới ARM64 và x86_64. ONNX Runtime sẽ được tải tự động bởi script thiết lập.

Yêu cầu

Thiết lập

git clone https://github.com/soniqo/speech-core.git
cd speech-core
./examples/linux/setup_linux.sh

cmake -B build \
    -DCMAKE_BUILD_TYPE=Release \
    -DSPEECH_CORE_WITH_ONNX=ON \
    -DSPEECH_CORE_BUILD_EXAMPLES=ON \
    -DORT_DIR=ort-linux
cmake --build build

# Tùy chọn — chạy các bài test tích hợp với mô hình thật
scripts/download_models.sh
SPEECH_MODEL_DIR=scripts/models ctest --test-dir build --output-on-failure

Ví dụ API C

#include <speech.h>

void on_event(const speech_event_t* event, void* ctx) {
    if (event->type == SPEECH_EVENT_TRANSCRIPTION)
        printf("%s\n", event->text);
}

speech_config_t cfg = speech_config_default();
cfg.model_dir = "/opt/speech/models";
speech_pipeline_t p = speech_create(cfg, on_event, NULL);
speech_start(p);
speech_push_audio(p, samples, 512);
Quan trọng

Khi biên dịch chéo bằng Yocto, hãy đặt ORT_DIR trỏ đến bản ONNX Runtime đã cài trong sysroot của bạn và dùng tệp toolchain CMake phù hợp.

Mã nguồn: github.com/soniqo/speech-core/tree/main/examples/linux

Bước tiếp theo