build(moonshine): compile moonshine C++ core from source, eliminating libmoonshine dependency#61
Draft
staging-devin-ai-integration[bot] wants to merge 4 commits intodevin/1772057250-moonshine-stt-pluginfrom
Conversation
… libmoonshine dependency Rewrites build.rs to download the moonshine v0.0.49 source tarball and compile its C++ core into a static archive using the cc crate. The plugin no longer requires a pre-installed libmoonshine shared library. ONNX Runtime (dynamic) is still needed at runtime and is auto-discovered from system paths or downloaded from GitHub releases as a fallback. Also adds: - CI lint job for moonshine in plugins.yml - Moonshine format check in plugins.yml - Bundle portability check for moonshine in verify_bundles.py Signed-off-by: StreamKit Devin <devin@streamkit.dev> Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Switch from eprintln! to cargo:warning= so download and compilation progress is visible to users during cargo build. The first build downloads moonshine source and ORT, then compiles 17 C++ files, which can take a few minutes with no other visible output. Signed-off-by: StreamKit Devin <devin@streamkit.dev> Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
…ference - Add plugin::native::moonshine to checkIfTranscriptionPipeline() so the convert UI shows transcription results instead of audio playback/download - Fix sample pipeline to use moonshine-base-en model (matches plugin.yml) instead of moonshine-tiny-en which is not defined as a downloadable model Signed-off-by: StreamKit Devin <devin@streamkit.dev> Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
The build.rs now checks the version of any discovered system libonnxruntime.so (from versioned symlinks like libonnxruntime.so.1.17.1) and rejects versions that don't match the required 1.23.x. If no compatible system ORT is found, it automatically downloads ORT 1.23.2. Previously, find_or_download_onnxruntime() accepted any libonnxruntime.so regardless of version. Users with an older system ORT (e.g., 1.17.1) would hit a runtime segfault because moonshine requires ORT API v23. Signed-off-by: StreamKit Devin <devin@streamkit.dev> Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
build(moonshine): compile C++ core from source via cc crate
Summary
Fixes the
rust-lld: error: unable to find library -lmoonshinebuild failure by replacing the dynamic linking approach with building the moonshine C++ core from source duringcargo build.Before:
build.rsemittedcargo:rustc-link-lib=moonshine, requiring users to manually build and installlibmoonshine.sofrom the moonshine repo via CMake. The moonshine project doesn't publish pre-built Linux x86_64 shared libraries, so this always failed out of the box.After:
build.rsdownloads moonshine v0.0.49 source from GitHub, compiles all 17 C++ source files into a static archive (libmoonshine_core.a) using thecccrate, and links statically. ONNX Runtime remains a dynamic dependency (libonnxruntime.so) — discovered from system paths or auto-downloaded from Microsoft's GitHub releases.Key changes:
build.rs: Full rewrite (~300 lines). Downloads/caches moonshine source, finds/downloads ORT with version validation, compiles C++ withcc, setsRPATH=$ORIGIN. Usescargo:warning=messages so download/compile progress is visible during builds (first build downloads ~100MB and compiles 17 C++ files, which takes a few minutes).Cargo.toml: Addedcc = "1.2"build-dependencyplugins.yml: Addedlint-moonshineCI job and moonshine format checkverify_bundles.py: Added moonshine bundle portability check forlibonnxruntime.soConvertView.tsx: Added moonshine to transcription pipeline detectionmoonshine-stt.yml: Fixed model reference to matchplugin.ymlEnvironment variable overrides:
MOONSHINE_SRC_DIR(local source checkout),ORT_LIB_DIR(pre-installed ORT location).Updates since last revision
find_or_download_onnxruntime()now checks the version of any systemlibonnxruntime.soby parsing versioned symlinks (e.g.,libonnxruntime.so.1.17.1). Incompatible versions are skipped with a warning, and the correct ORT 1.23.2 is downloaded automatically. Previously, any system ORT was accepted regardless of version, causing a runtime segfault when moonshine (requiring ORT API v23) loaded an older ORT (e.g., 1.17.1). IfORT_LIB_DIRis set explicitly with an incompatible version, the build panics with a clear error message.plugin::native::moonshinetocheckIfTranscriptionPipeline()inConvertView.tsxso the Convert UI shows the transcription display instead of the audio playback/download interface when running the moonshine sample pipeline.moonshine-stt.ymlto referencemoonshine-base-en/model_arch: baseinstead ofmoonshine-tiny-en/model_arch: tiny. The previous reference didn't match any model defined inplugin.yml, which was contributing to the "Plugin failed to create instance" runtime error.eprintln!toprintln!("cargo:warning=...")so users see download and compilation progress duringcargo buildinstead of a frozen progress bar.Review & Testing Checklist for Human
just build-plugin-native-moonshine), load the moonshine sample pipeline in Convert, upload an audio file, and verify transcription output appears. Critical: While the ORT version mismatch and model path issues are now fixed, the pipeline hasn't been tested with actual audio. There may be additional runtime issues (model file structure, initialization, etc.).libonnxruntime.soexists without versioned symlinks (e.g., custom installs),ort_version_from_dir()returnsNoneand the system ORT is skipped. Verify this behavior is acceptable, or if we should addreadelf -dfallback to check SONAME..cppfilenames match moonshine v0.0.49's actual source tree. The list was derived from their CMakeLists.txt but any mismatch will cause build failures. Cross-reference with https://github.com/moonshine-ai/moonshine/tree/v0.0.49/corecurlandtaron the host. These are standard on Linux but the build script will panic if they're missing. Verify this is acceptable.Notes
cargo build --releasesucceeds,cargo clippy -- -D warningspasses,cargo fmtpasses, all 212 project tests passcargo buildnow correctly skips the old version with warning "Skipping onnxruntime 1.17 at /usr/local/lib (need 1.23)" and downloads ORT 1.23.2 instead. The segfault is resolved.whisper-rsbuilds whisper.cpp from sourceonnxruntime-linux-x64. Confirm this is acceptable or if macOS/ARM support is needed.Requested by @streamer45 · Devin session