Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
transcribefile: CPU build of transcribe.cpp + sync to df1a4ad (#1007)
Davide Eynard12818131fd85
diff --git a/.gitmodules b/.gitmodulesindex 199e08c8..bb112767 100644--- a/.gitmodules+++ b/.gitmodules@@ -10,3 +10,6 @@[submodule "third_party/zipalign"]path = third_party/zipalignurl = https://github.com/jart/zipalign.git+[submodule "transcribe.cpp"]+ path = transcribe.cpp+ url = https://github.com/handy-computer/transcribe.cpp.gitdiff --git a/Makefile b/Makefileindex e7ba1a9e..e342c411 100644--- a/Makefile+++ b/Makefile@@ -16,9 +16,11 @@ include build/rules.mkinclude third_party/BUILD.mkinclude llama.cpp/BUILD.mkinclude whisper.cpp/BUILD.mk+include transcribe.cpp/BUILD.mkinclude stable-diffusion.cpp/BUILD.mkinclude llamafile/BUILD.mkinclude whisperfile/BUILD.mk+include transcribefile/BUILD.mkinclude diffusionfile/BUILD.mkinclude tests/BUILD.mkendif@@ -31,6 +33,8 @@ o/$(MODE)/: o/$(MODE)/llamafile \o/$(MODE)/whisper.cpp \o/$(MODE)/stable-diffusion.cpp \o/$(MODE)/whisperfile \+ o/$(MODE)/transcribe.cpp \+ o/$(MODE)/transcribefile \o/$(MODE)/diffusionfile \o/$(MODE)/third_party/zipalign@@ -108,6 +112,13 @@ setup: # Initialize and configure all dependencies (submodules, patches, etc.)@echo "Applying llama.cpp patches..."@export TMPDIR=$$(pwd)/o/tmp && ./llama.cpp.patches/apply-patches.sh+ @if [ ! -f transcribe.cpp/.git ]; then \+ echo "Initializing transcribe.cpp submodule..."; \+ git submodule update --init transcribe.cpp; \+ fi+ @echo "Applying transcribe.cpp patches..."+ @export TMPDIR=$$(pwd)/o/tmp && ./transcribe.cpp.patches/apply-patches.sh+@if [ ! -f third_party/zipalign/.git ]; then \echo "Initializing zipalign submodule..."; \git submodule update --init third_party/zipalign; \@@ -118,7 +129,7 @@ setup: # Initialize and configure all dependencies (submodules, patches, etc.).PHONY: reset-reporeset-repo: # Reset all submodules to their original state (removes patches or any other change)@echo "Resetting submodules to original state..."- @for dir in llama.cpp whisper.cpp stable-diffusion.cpp third_party/zipalign; do \+ @for dir in llama.cpp whisper.cpp stable-diffusion.cpp transcribe.cpp third_party/zipalign; do \if [ -e "$$dir" ]; then \echo "Removing $$dir..."; \rm -rf "$$dir"; \diff --git a/tests/BUILD.mk b/tests/BUILD.mkindex 335dead9..9ec82eff 100644--- a/tests/BUILD.mk+++ b/tests/BUILD.mk@@ -156,6 +156,24 @@ o/$(MODE)/tests/backend_ops_test: \@mkdir -p $(@D)$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)+# ==============================================================================+# Smoke test: transcribefile APE+# ==============================================================================+#+# Subprocess-style regression on the transcribefile binary itself.+# Layer 1: model-free probes (--help, WAV duration line) — always runs.+# Layer 2: parakeet end-to-end, gated on TRANSCRIBEFILE_PARAKEET_GGUF+# (skip-on-missing, never fails `make check` for absent model).+# The script is the test; we don't have an executable to plug %.runs into,+# so we define a one-off recipe that emits the stamp on success.++o/$(MODE)/tests/transcribefile_smoke.runs: \+ o/$(MODE)/transcribefile/transcribefile \+ tests/transcribefile_smoke.sh+ @mkdir -p $(@D)+ bash tests/transcribefile_smoke.sh o/$(MODE)/transcribefile/transcribefile+ @touch $@+# ==============================================================================# Phony targets# ==============================================================================@@ -164,4 +182,5 @@ o/$(MODE)/tests/backend_ops_test: \o/$(MODE)/tests: \o/$(MODE)/tests/extract_data_uris_test.runs \o/$(MODE)/tests/fa_helpers_test.runs \- o/$(MODE)/tests/gpu_backend_test.runs+ o/$(MODE)/tests/gpu_backend_test.runs \+ o/$(MODE)/tests/transcribefile_smoke.runsdiff --git a/tests/transcribefile_smoke.sh b/tests/transcribefile_smoke.shnew file mode 100755index 00000000..bd3bb696--- /dev/null+++ b/tests/transcribefile_smoke.sh@@ -0,0 +1,76 @@+#!/usr/bin/env bash+# transcribefile_smoke.sh — regression smoke for the transcribefile APE.+#+# Two layers:+# 1. Model-free probes — always run. Catches CLI argv / WAV-loader /+# help-text regressions without needing any model artifact.+# 2. Parakeet end-to-end — gated on TRANSCRIBEFILE_PARAKEET_GGUF. Skipped+# (with a warning, not a failure) when the model isn't available, so+# `make check` stays green on machines without the model.+#+# Usage:+# tests/transcribefile_smoke.sh <path-to-transcribefile-binary>+#+# Env:+# TRANSCRIBEFILE_PARAKEET_GGUF Path to a parakeet GGUF; if unset or the+# file is missing, layer 2 is skipped.++set -euo pipefail++APE="${1:-}"+if [ -z "$APE" ] || [ ! -x "$APE" ]; then+ echo "FAIL: argv[1] must point at an executable transcribefile binary" >&2+ echo " got: '$APE'" >&2+ exit 2+fi++# Resolve repo root from this script's location so samples/ paths work+# no matter the cwd `make` invokes us from.+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"+SAMPLE="$REPO_ROOT/transcribe.cpp/samples/jfk.wav"++if [ ! -f "$SAMPLE" ]; then+ echo "FAIL: sample wav not found at $SAMPLE" >&2+ echo " (is the transcribe.cpp submodule initialized?)" >&2+ exit 2+fi++pass() { printf ' ok %s\n' "$1"; }+fail() { printf ' FAIL %s\n' "$1" >&2; exit 1; }++echo "[smoke] layer 1 — model-free probes"++# --help should exit 0 and print the usage banner.+out=$("$APE" --help 2>&1) || fail "--help exited non-zero"+echo "$out" | grep -q '^usage:' || fail "--help missing 'usage:' banner"+pass "--help prints usage banner"++# Running on a wav without -m should still exit 0 and print the+# parsed-WAV duration line. This mirrors upstream's transcribe_cli_smoke+# CTest: it exercises argv parsing + WAV loader without needing a model.+out=$("$APE" "$SAMPLE" 2>&1) || fail "wav-only run exited non-zero"+echo "$out" | grep -q 'duration:' || fail "wav-only run missing 'duration:' line"+echo "$out" | grep -qE 'duration:.*11\.0' || fail "duration should report ~11.0 s for jfk.wav"+pass "wav-only run reports duration (no model required)"++echo "[smoke] layer 2 — parakeet end-to-end"++MODEL="${TRANSCRIBEFILE_PARAKEET_GGUF:-}"+if [ -z "$MODEL" ] || [ ! -f "$MODEL" ]; then+ echo " SKIP parakeet end-to-end: TRANSCRIBEFILE_PARAKEET_GGUF" \+ "not set or file missing" >&2+ echo " (set it to a parakeet-tdt GGUF to run this layer)" >&2+ exit 0+fi++# Real transcription run. Asserts:+# - exit 0+# - timings / realtime lines present (so we know it actually decoded)+# - the JFK quote contains 'country' (sanity-check the decoder didn't+# silently produce garbage)+out=$("$APE" -m "$MODEL" "$SAMPLE" 2>&1) || fail "parakeet run exited non-zero"+echo "$out" | grep -q 'realtime:' || fail "parakeet output missing 'realtime:' line"+echo "$out" | grep -qi 'country' || fail "parakeet transcription missing 'country'"+realtime=$(echo "$out" | grep -oE 'realtime:[[:space:]]+[0-9]+x' | head -1 || true)+pass "parakeet transcribes jfk.wav (${realtime:-realtime: ?})"diff --git a/tools/check_patches.sh b/tools/check_patches.shindex 72de0e05..e284f2dc 100755--- a/tools/check_patches.sh+++ b/tools/check_patches.sh@@ -1,9 +1,21 @@-PATCHES_DIR="llama.cpp.patches/patches"+#!/usr/bin/env bash+# Dry-run apply every patch in a patches directory to flag conflicts.+# Usage: tools/check_patches.sh [patches-dir] (default: llama.cpp.patches/patches)+#+# `git apply --check` failures are collected across the whole loop rather than+# aborting on the first — the point of the tool is to list every conflicting+# patch in one pass. The script exits non-zero if any patch fails.+set -uo pipefail+PATCHES_DIR="${1:-llama.cpp.patches/patches}"++rc=0for patch_file in "$PATCHES_DIR"/*.patch; doif [ -f "$patch_file" ]; thenecho "Applying $(basename "$patch_file")..."- git apply --check "$patch_file"+ git apply --check "$patch_file" || rc=1#patch -p1 --dry-run < "$patch_file"fidone++exit $rcdiff --git a/transcribe.cpp b/transcribe.cppnew file mode 160000index 00000000..df1a4adf--- /dev/null+++ b/transcribe.cpp@@ -0,0 +1 @@+Subproject commit df1a4adfb1aec59e399a20dd992f93925eb09f25diff --git a/transcribe.cpp.patches/apply-patches.sh b/transcribe.cpp.patches/apply-patches.shnew file mode 100755index 00000000..21f89a0a--- /dev/null+++ b/transcribe.cpp.patches/apply-patches.sh@@ -0,0 +1,49 @@+#!/bin/bash+# Apply llamafile patches to the transcribe.cpp submodule.+#+# Mirrors whisper.cpp.patches/apply-patches.sh:+# 1. copy everything under llamafile-files/ into the submodule root+# (this is how transcribe.cpp/BUILD.mk gets created)+# 2. run renames.sh for any file moves+# 3. apply every patch in patches/ with `patch -p1`+#+# The submodule is left dirty on purpose; these changes are never committed+# into the submodule. To reset:+# cd transcribe.cpp && git reset --hard && git clean -fdx++set -e++SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+TRANSCRIBE_DIR="$SCRIPT_DIR/../transcribe.cpp"+PATCHES_DIR="$SCRIPT_DIR/patches"+LLAMAFILE_FILES_DIR="$SCRIPT_DIR/llamafile-files"++cd "$TRANSCRIBE_DIR"++# Refuse to run on a dirty tree so we never stack patches on top of patches.+if [ -n "$(git status --porcelain)" ]; then+ echo "Git status is dirty. Please commit or stash your changes before applying patches."+ exit 1+fi++echo "Applying patches to transcribe.cpp submodule..."++echo "Copying all files in llamafile-files to root directory..."+cp -r "$LLAMAFILE_FILES_DIR"/* .++"$SCRIPT_DIR/renames.sh"++cd ..+echo "Applying modifications to upstream files..."+for patch_file in "$PATCHES_DIR"/*.patch; do+ if [ -f "$patch_file" ]; then+ echo "Applying $(basename "$patch_file")..."+ patch -p1 < "$patch_file"+ fi+done++echo ""+echo "Patches applied successfully!"+echo "Note: These changes are not committed to the submodule."+echo "To reset the submodule to its clean state, run:"+echo " cd transcribe.cpp && git reset --hard && git clean -fdx"diff --git a/transcribe.cpp.patches/llamafile-files/BUILD.mk b/transcribe.cpp.patches/llamafile-files/BUILD.mknew file mode 100644index 00000000..302149ca--- /dev/null+++ b/transcribe.cpp.patches/llamafile-files/BUILD.mk@@ -0,0 +1,314 @@+#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐+#── vi: set noet ft=make ts=8 sw=8 fenc=utf-8 :vi ────────────────────┘+#+# BUILD.mk for transcribe.cpp (CPU-only build with cosmocc)+#+# transcribe.cpp ships its OWN vendored ggml (ggml-org/ggml @ a pinned+# SHA, see ggml/UPSTREAM) which differs from llama.cpp/ggml, so we build+# that ggml here rather than reusing llama.cpp's objects — the same+# approach whisper.cpp uses.+#+# Derived from transcribe.cpp's CMake configuration:+# ggml/src/CMakeLists.txt, ggml/src/ggml-cpu/CMakeLists.txt, src/CMakeLists.txt+#+# The ggml CPU build mirrors llama.cpp's proven cross-arch recipe:+# -DGGML_CPU_GENERIC plus the top-level quants.c/repack.cpp only (no+# arch/x86 or arch/arm sources), so a single cosmocc fat binary works on+# both x86_64 and aarch64.++PKGS += TRANSCRIBE_CPP++# ==============================================================================+# Version Information+# ==============================================================================++TRANSCRIBE_GGML_VERSION := 0.15.2+TRANSCRIBE_GGML_COMMIT := $(shell cd transcribe.cpp/ggml 2>/dev/null && cat UPSTREAM 2>/dev/null | sed -n 's/^sha:[[:space:]]*//p' | cut -c1-7 || echo "unknown")++# ==============================================================================+# Include Paths+# ==============================================================================++TRANSCRIBE_GGML_INCS := \+ -iquote transcribe.cpp/ggml/include \+ -iquote transcribe.cpp/ggml/src \+ -iquote transcribe.cpp/ggml/src/ggml-cpu++TRANSCRIBE_LIB_INCS := \+ -iquote transcribe.cpp/include \+ -iquote transcribe.cpp/src \+ -iquote transcribe.cpp/ggml/include \+ -iquote transcribe.cpp/ggml/src \+ -isystem $(COSMOCC)/include/third_party/zlib++# ==============================================================================+# Common Compiler Flags+# ==============================================================================++TRANSCRIBE_GGML_CPPFLAGS := \+ -DGGML_USE_CPU \+ -DGGML_CPU_GENERIC \+ -DGGML_USE_CPU_REPACK \+ -DGGML_SCHED_MAX_COPIES=4 \+ -DGGML_VERSION=\"$(TRANSCRIBE_GGML_VERSION)\" \+ -DGGML_COMMIT=\"$(TRANSCRIBE_GGML_COMMIT)\"++# TRANSCRIBE_HAS_BLAS is intentionally NOT defined: the decoder falls+# back to a correct (if slower) scalar loop, avoiding a BLAS dependency+# under cosmocc.+#+# MINIZ_NO_* defines mirror upstream src/CMakeLists.txt: they trim the+# vendored miniz to the compress-only deflate path Whisper's+# compression-ratio metric needs, and avoid colliding with any system+# zlib downstream (NO_ZLIB_COMPATIBLE_NAMES — call sites use the+# mz_-prefixed API).+TRANSCRIBE_LIB_CPPFLAGS := \+ -DTRANSCRIBE_BUILD \+ -DGGML_SCHED_MAX_COPIES=4 \+ -DMINIZ_NO_INFLATE_APIS \+ -DMINIZ_NO_STDIO \+ -DMINIZ_NO_TIME \+ -DMINIZ_NO_ZLIB_COMPATIBLE_NAMES++# ==============================================================================+# GGML Sources (transcribe.cpp/ggml/src — vendored ggml 0.9.8)+# ==============================================================================++TRANSCRIBE_GGML_SRCS_C := \+ transcribe.cpp/ggml/src/ggml-alloc.c \+ transcribe.cpp/ggml/src/ggml-quants.c \+ transcribe.cpp/ggml/src/ggml.c \+ transcribe.cpp/ggml/src/ggml-cpu/ggml-cpu.c \+ transcribe.cpp/ggml/src/ggml-cpu/quants.c++TRANSCRIBE_GGML_SRCS_CPP := \+ transcribe.cpp/ggml/src/ggml-backend-dl.cpp \+ transcribe.cpp/ggml/src/ggml-backend-meta.cpp \+ transcribe.cpp/ggml/src/ggml-backend-reg.cpp \+ transcribe.cpp/ggml/src/ggml-backend.cpp \+ transcribe.cpp/ggml/src/ggml-opt.cpp \+ transcribe.cpp/ggml/src/ggml-threading.cpp \+ transcribe.cpp/ggml/src/ggml.cpp \+ transcribe.cpp/ggml/src/gguf.cpp \+ transcribe.cpp/ggml/src/ggml-cpu/binary-ops.cpp \+ transcribe.cpp/ggml/src/ggml-cpu/ggml-cpu.cpp \+ transcribe.cpp/ggml/src/ggml-cpu/hbm.cpp \+ transcribe.cpp/ggml/src/ggml-cpu/ops.cpp \+ transcribe.cpp/ggml/src/ggml-cpu/repack.cpp \+ transcribe.cpp/ggml/src/ggml-cpu/traits.cpp \+ transcribe.cpp/ggml/src/ggml-cpu/unary-ops.cpp \+ transcribe.cpp/ggml/src/ggml-cpu/vec.cpp \+ transcribe.cpp/ggml/src/ggml-cpu/amx/amx.cpp \+ transcribe.cpp/ggml/src/ggml-cpu/amx/mmq.cpp++# ==============================================================================+# Transcribe Library Sources (transcribe.cpp/src — from src/CMakeLists.txt)+# ==============================================================================++TRANSCRIBE_LIB_SRCS_CPP := \+ transcribe.cpp/src/transcribe.cpp \+ transcribe.cpp/src/transcribe-loader.cpp \+ transcribe.cpp/src/transcribe-arch.cpp \+ transcribe.cpp/src/transcribe-meta.cpp \+ transcribe.cpp/src/transcribe-kaldi-fbank.cpp \+ transcribe.cpp/src/transcribe-mel.cpp \+ transcribe.cpp/src/transcribe-model.cpp \+ transcribe.cpp/src/transcribe-tokenizer.cpp \+ transcribe.cpp/src/transcribe-unicode.cpp \+ transcribe.cpp/src/transcribe-unicode-data.cpp \+ transcribe.cpp/src/transcribe-debug.cpp \+ transcribe.cpp/src/transcribe-env.cpp \+ transcribe.cpp/src/transcribe-flash-policy.cpp \+ transcribe.cpp/src/transcribe-backend.cpp \+ transcribe.cpp/src/transcribe-load-common.cpp \+ transcribe.cpp/src/transcribe-weights-util.cpp \+ transcribe.cpp/src/transcribe-bin-loader.cpp \+ transcribe.cpp/src/transcribe-batch-util.cpp \+ transcribe.cpp/src/conformer/conformer.cpp \+ transcribe.cpp/src/sanm/sanm.cpp \+ transcribe.cpp/src/causal_lm/causal_lm.cpp \+ transcribe.cpp/src/granite_conformer/shaw_attn.cpp \+ transcribe.cpp/src/arch/parakeet/model.cpp \+ transcribe.cpp/src/arch/parakeet/capabilities.cpp \+ transcribe.cpp/src/arch/parakeet/weights.cpp \+ transcribe.cpp/src/arch/parakeet/encoder.cpp \+ transcribe.cpp/src/arch/parakeet/decoder.cpp \+ transcribe.cpp/src/arch/cohere/model.cpp \+ transcribe.cpp/src/arch/cohere/capabilities.cpp \+ transcribe.cpp/src/arch/cohere/weights.cpp \+ transcribe.cpp/src/arch/cohere/encoder.cpp \+ transcribe.cpp/src/arch/cohere/decoder.cpp \+ transcribe.cpp/src/arch/canary/model.cpp \+ transcribe.cpp/src/arch/canary/capabilities.cpp \+ transcribe.cpp/src/arch/canary/weights.cpp \+ transcribe.cpp/src/arch/canary/encoder.cpp \+ transcribe.cpp/src/arch/canary/decoder.cpp \+ transcribe.cpp/src/arch/qwen3_asr/model.cpp \+ transcribe.cpp/src/arch/qwen3_asr/capabilities.cpp \+ transcribe.cpp/src/arch/qwen3_asr/weights.cpp \+ transcribe.cpp/src/arch/qwen3_asr/encoder.cpp \+ transcribe.cpp/src/arch/qwen3_asr/decoder.cpp \+ transcribe.cpp/src/arch/canary_qwen/model.cpp \+ transcribe.cpp/src/arch/canary_qwen/capabilities.cpp \+ transcribe.cpp/src/arch/canary_qwen/weights.cpp \+ transcribe.cpp/src/arch/canary_qwen/encoder.cpp \+ transcribe.cpp/src/arch/canary_qwen/decoder.cpp \+ transcribe.cpp/src/arch/whisper/model.cpp \+ transcribe.cpp/src/arch/whisper/capabilities.cpp \+ transcribe.cpp/src/arch/whisper/weights.cpp \+ transcribe.cpp/src/arch/whisper/encoder.cpp \+ transcribe.cpp/src/arch/whisper/decoder.cpp \+ transcribe.cpp/src/arch/whisper/bin_load.cpp \+ transcribe.cpp/src/arch/whisper/public.cpp \+ transcribe.cpp/src/arch/moonshine/model.cpp \+ transcribe.cpp/src/arch/moonshine/capabilities.cpp \+ transcribe.cpp/src/arch/moonshine/weights.cpp \+ transcribe.cpp/src/arch/moonshine/encoder.cpp \+ transcribe.cpp/src/arch/moonshine/decoder.cpp \+ transcribe.cpp/src/arch/moonshine_streaming/model.cpp \+ transcribe.cpp/src/arch/moonshine_streaming/capabilities.cpp \+ transcribe.cpp/src/arch/moonshine_streaming/weights.cpp \+ transcribe.cpp/src/arch/moonshine_streaming/encoder.cpp \+ transcribe.cpp/src/arch/moonshine_streaming/decoder.cpp \+ transcribe.cpp/src/arch/sensevoice/model.cpp \+ transcribe.cpp/src/arch/sensevoice/capabilities.cpp \+ transcribe.cpp/src/arch/sensevoice/weights.cpp \+ transcribe.cpp/src/arch/sensevoice/encoder.cpp \+ transcribe.cpp/src/arch/funasr_nano/model.cpp \+ transcribe.cpp/src/arch/funasr_nano/capabilities.cpp \+ transcribe.cpp/src/arch/funasr_nano/weights.cpp \+ transcribe.cpp/src/arch/funasr_nano/encoder.cpp \+ transcribe.cpp/src/arch/funasr_nano/decoder.cpp \+ transcribe.cpp/src/arch/funasr_nano/adaptor.cpp \+ transcribe.cpp/src/arch/gigaam/model.cpp \+ transcribe.cpp/src/arch/gigaam/capabilities.cpp \+ transcribe.cpp/src/arch/gigaam/weights.cpp \+ transcribe.cpp/src/arch/gigaam/encoder.cpp \+ transcribe.cpp/src/arch/gigaam/decoder.cpp \+ transcribe.cpp/src/arch/gigaam/mel.cpp \+ transcribe.cpp/src/arch/granite/model.cpp \+ transcribe.cpp/src/arch/granite/capabilities.cpp \+ transcribe.cpp/src/arch/granite/weights.cpp \+ transcribe.cpp/src/arch/granite/encoder.cpp \+ transcribe.cpp/src/arch/granite/projector.cpp \+ transcribe.cpp/src/arch/granite/decoder.cpp \+ transcribe.cpp/src/arch/granite_nar/model.cpp \+ transcribe.cpp/src/arch/granite_nar/capabilities.cpp \+ transcribe.cpp/src/arch/granite_nar/weights.cpp \+ transcribe.cpp/src/arch/granite_nar/encoder.cpp \+ transcribe.cpp/src/arch/granite_nar/projector.cpp \+ transcribe.cpp/src/arch/granite_nar/decoder.cpp \+ transcribe.cpp/src/arch/medasr/model.cpp \+ transcribe.cpp/src/arch/medasr/capabilities.cpp \+ transcribe.cpp/src/arch/medasr/weights.cpp \+ transcribe.cpp/src/arch/medasr/encoder.cpp \+ transcribe.cpp/src/arch/voxtral/model.cpp \+ transcribe.cpp/src/arch/voxtral/capabilities.cpp \+ transcribe.cpp/src/arch/voxtral/weights.cpp \+ transcribe.cpp/src/arch/voxtral/encoder.cpp \+ transcribe.cpp/src/arch/voxtral/decoder.cpp \+ transcribe.cpp/src/arch/voxtral_realtime/model.cpp \+ transcribe.cpp/src/arch/voxtral_realtime/capabilities.cpp \+ transcribe.cpp/src/arch/voxtral_realtime/weights.cpp \+ transcribe.cpp/src/arch/voxtral_realtime/encoder.cpp \+ transcribe.cpp/src/arch/voxtral_realtime/decoder.cpp++# Vendored miniz (C) — only consumer is arch/whisper/model.cpp's+# compression-ratio heuristic. Built into the transcribe lib so the+# binary stays self-contained (no system zlib).+TRANSCRIBE_LIB_SRCS_C := \+ transcribe.cpp/src/third_party/miniz/miniz.c++# ==============================================================================+# Object Files+# ==============================================================================++TRANSCRIBE_GGML_OBJS := \+ $(TRANSCRIBE_GGML_SRCS_C:%.c=o/$(MODE)/%.c.o) \+ $(TRANSCRIBE_GGML_SRCS_CPP:%.cpp=o/$(MODE)/%.cpp.o)++TRANSCRIBE_LIB_OBJS := \+ $(TRANSCRIBE_LIB_SRCS_CPP:%.cpp=o/$(MODE)/%.cpp.o) \+ $(TRANSCRIBE_LIB_SRCS_C:%.c=o/$(MODE)/%.c.o)++# All static-library objects.+TRANSCRIBE_CPP_OBJS := \+ $(TRANSCRIBE_GGML_OBJS) \+ $(TRANSCRIBE_LIB_OBJS)++# ==============================================================================+# Static Library+# ==============================================================================++o/$(MODE)/transcribe.cpp/transcribe.cpp.a: $(TRANSCRIBE_CPP_OBJS)++# ==============================================================================+# Compilation Rules — GGML+# ==============================================================================++$(TRANSCRIBE_GGML_SRCS_C:%.c=o/$(MODE)/%.c.o): \+ o/$(MODE)/%.c.o: %.c transcribe.cpp/BUILD.mk $(COSMOCC)+ @mkdir -p $(@D)+ $(COMPILE.c) $(TRANSCRIBE_GGML_INCS) $(TRANSCRIBE_GGML_CPPFLAGS) -o $@ $<++$(TRANSCRIBE_GGML_SRCS_CPP:%.cpp=o/$(MODE)/%.cpp.o): \+ o/$(MODE)/%.cpp.o: %.cpp transcribe.cpp/BUILD.mk $(COSMOCC)+ @mkdir -p $(@D)+ $(COMPILE.cc) $(TRANSCRIBE_GGML_INCS) $(TRANSCRIBE_GGML_CPPFLAGS) -o $@ $<++# ==============================================================================+# Compilation Rules — Transcribe Library+# ==============================================================================++$(TRANSCRIBE_LIB_SRCS_CPP:%.cpp=o/$(MODE)/%.cpp.o): \+ o/$(MODE)/%.cpp.o: %.cpp transcribe.cpp/BUILD.mk $(COSMOCC)+ @mkdir -p $(@D)+ $(COMPILE.cc) $(TRANSCRIBE_LIB_INCS) $(TRANSCRIBE_LIB_CPPFLAGS) -o $@ $<++# Vendored miniz.c uses third-party style that trips strict warnings;+# silence them for this one file (upstream does the same via -w).+$(TRANSCRIBE_LIB_SRCS_C:%.c=o/$(MODE)/%.c.o): \+ o/$(MODE)/%.c.o: %.c transcribe.cpp/BUILD.mk $(COSMOCC)+ @mkdir -p $(@D)+ $(COMPILE.c) $(TRANSCRIBE_LIB_INCS) $(TRANSCRIBE_LIB_CPPFLAGS) -w -o $@ $<++# ==============================================================================+# Compiler Flag Overrides (mirror llama.cpp's cosmocc recipe)+# ==============================================================================+# -mgcc is required for files that use errno in switch statements+# (cosmopolitan's errno is a dynamic value, not a compile-time constant).++# Memory allocation and backend.+o/$(MODE)/transcribe.cpp/ggml/src/ggml-alloc.c.o \+o/$(MODE)/transcribe.cpp/ggml/src/ggml-backend.cpp.o: \+ private CCFLAGS += -mgcc++# Backend registration — optimize for size.+o/$(MODE)/transcribe.cpp/ggml/src/ggml-backend-reg.cpp.o: \+ private CCFLAGS += -Os++# Core GGML and vector operations — optimize for performance.+o/$(MODE)/transcribe.cpp/ggml/src/ggml.c.o \+o/$(MODE)/transcribe.cpp/ggml/src/ggml-cpu/vec.cpp.o \+o/$(MODE)/transcribe.cpp/ggml/src/ggml-cpu/ops.cpp.o \+o/$(MODE)/transcribe.cpp/ggml/src/ggml-cpu/binary-ops.cpp.o \+o/$(MODE)/transcribe.cpp/ggml/src/ggml-cpu/unary-ops.cpp.o: \+ private CCFLAGS += -O3 -mgcc++# Quantization — critical hot path.+o/$(MODE)/transcribe.cpp/ggml/src/ggml-quants.c.o \+o/$(MODE)/transcribe.cpp/ggml/src/ggml-cpu/quants.c.o: \+ private CCFLAGS += -O3 -mgcc++# ==============================================================================+# Dependencies+# ==============================================================================++$(TRANSCRIBE_CPP_OBJS): transcribe.cpp/BUILD.mk++# ==============================================================================+# Main Target+# ==============================================================================++.PHONY: o/$(MODE)/transcribe.cpp+o/$(MODE)/transcribe.cpp: o/$(MODE)/transcribe.cpp/transcribe.cpp.adiff --git a/transcribe.cpp.patches/patches/examples_cli_main.cpp.patch b/transcribe.cpp.patches/patches/examples_cli_main.cpp.patchnew file mode 100644index 00000000..b33c83f6--- /dev/null+++ b/transcribe.cpp.patches/patches/examples_cli_main.cpp.patch@@ -0,0 +1,29 @@+diff --git a/examples/cli/main.cpp b/examples/cli/main.cpp+--- a/transcribe.cpp/examples/cli/main.cpp++++ b/transcribe.cpp/examples/cli/main.cpp+@@ -595,7 +595,11 @@ void log_cb(transcribe_log_level level, const char * msg, void * userdata) {++ } // namespace++-int main(int argc, char ** argv) {++// Core CLI logic. When built with -DTRANSCRIBEFILE this is invoked from++// transcribefile's own main() (which first loads bundled /zip/.args); the++// standalone main() below is then dropped so transcribefile owns the entry++// point. Without -DTRANSCRIBEFILE this builds as a vanilla CLI.++int transcribe_cli_main(int argc, char ** argv) {+ cli_args args;+ if (!parse_args(argc, argv, args)) {+ print_usage(argv[0]);+@@ -1284,3 +1288,12 @@ int main(int argc, char ** argv) {++ return EXIT_SUCCESS;+ }++++// Standalone entry point. Not compiled into transcribefile (which provides its++// own main() that also loads bundled /zip/.args), so the vanilla CLI keeps++// working when built outside the llamafile tree.++#ifndef TRANSCRIBEFILE++int main(int argc, char ** argv) {++ return transcribe_cli_main(argc, argv);++}++#endifdiff --git a/transcribe.cpp.patches/renames.sh b/transcribe.cpp.patches/renames.shnew file mode 100755index 00000000..5b78dec9--- /dev/null+++ b/transcribe.cpp.patches/renames.sh@@ -0,0 +1,8 @@+#!/usr/bin/env bash+set -euo pipefail++# Use this script if you just want to move files from one directory to another.+# For instance:+# mv common/base64.hpp base64.h+#+# Nothing to rename for transcribe.cpp yet.diff --git a/transcribefile/BUILD.mk b/transcribefile/BUILD.mknew file mode 100644index 00000000..57bcc629--- /dev/null+++ b/transcribefile/BUILD.mk@@ -0,0 +1,82 @@+#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐+#── vi: set noet ft=make ts=8 sw=8 fenc=utf-8 :vi ────────────────────┘+#+# BUILD.mk for transcribefile.+#+# Entry point is transcribefile/main.cpp, a thin wrapper that loads default+# arguments from the executable's own zip store (/zip/.args, via cosmo_args)+# and then calls transcribe.cpp's example CLI logic. The CLI lives in+# transcribe.cpp/examples/cli/main.cpp, compiled with -DTRANSCRIBEFILE so its+# main() is renamed to transcribe_cli_main() and our wrapper owns the entry+# point (the standalone CLI main() is dropped). The WAV loader comes from+# transcribe.cpp/examples/common/wav.cpp. Everything links against the+# cosmocc-built transcribe.cpp.a.++PKGS += TRANSCRIBEFILE++# Version string surfaced by `transcribefile --version`.+TRANSCRIBEFILE_VERSION_STRING := $(shell cd transcribe.cpp 2>/dev/null && git describe --tags --always 2>/dev/null || echo "0.0.0-dev")++# ==============================================================================+# Sources (our wrapper + upstream example CLI + WAV loader)+# ==============================================================================++TRANSCRIBEFILE_SRCS_CPP := \+ transcribefile/main.cpp \+ transcribe.cpp/examples/cli/main.cpp \+ transcribe.cpp/examples/common/wav.cpp++# Our own code (cosmocc libc compatibility shims, etc.).+TRANSCRIBEFILE_SRCS_C := \+ transcribefile/cosmo_compat.c++TRANSCRIBEFILE_CPP_OBJS := $(TRANSCRIBEFILE_SRCS_CPP:%.cpp=o/$(MODE)/%.cpp.o)+TRANSCRIBEFILE_C_OBJS := $(TRANSCRIBEFILE_SRCS_C:%.c=o/$(MODE)/%.c.o)++TRANSCRIBEFILE_OBJS := \+ $(TRANSCRIBEFILE_CPP_OBJS) \+ $(TRANSCRIBEFILE_C_OBJS)++TRANSCRIBEFILE_INCLUDES := \+ -iquote transcribe.cpp/include \+ -iquote transcribe.cpp/examples/common++# -DTRANSCRIBEFILE renames the upstream CLI main() to transcribe_cli_main();+# the version string feeds `--version`. dr_wav.h trips a couple of warnings+# that are noise here.+TRANSCRIBEFILE_CPPFLAGS := \+ -DTRANSCRIBEFILE \+ -DTRANSCRIBEFILE_VERSION_STRING=\"$(TRANSCRIBEFILE_VERSION_STRING)\" \+ -Wno-sign-compare \+ -Wno-unused-function++# ==============================================================================+# Compilation Rules+# ==============================================================================++$(TRANSCRIBEFILE_CPP_OBJS): o/$(MODE)/%.cpp.o: %.cpp transcribefile/BUILD.mk $(COSMOCC)+ @mkdir -p $(@D)+ $(COMPILE.cc) $(TRANSCRIBEFILE_INCLUDES) $(TRANSCRIBEFILE_CPPFLAGS) -o $@ $<++$(TRANSCRIBEFILE_C_OBJS): o/$(MODE)/%.c.o: %.c transcribefile/BUILD.mk $(COSMOCC)+ @mkdir -p $(@D)+ $(COMPILE.c) -o $@ $<++# ==============================================================================+# Executable+# ==============================================================================++o/$(MODE)/transcribefile/transcribefile: \+ $(TRANSCRIBEFILE_OBJS) \+ o/$(MODE)/transcribe.cpp/transcribe.cpp.a+ @mkdir -p $(@D)+ $(LINK.o) $(TRANSCRIBEFILE_OBJS) \+ o/$(MODE)/transcribe.cpp/transcribe.cpp.a \+ $(LOADLIBES) $(LDLIBS) -o $@++# ==============================================================================+# Main Target+# ==============================================================================++.PHONY: o/$(MODE)/transcribefile+o/$(MODE)/transcribefile: o/$(MODE)/transcribefile/transcribefilediff --git a/transcribefile/cosmo_compat.c b/transcribefile/cosmo_compat.cnew file mode 100644index 00000000..3e71a7cf--- /dev/null+++ b/transcribefile/cosmo_compat.c@@ -0,0 +1,17 @@+// Cosmopolitan libc compatibility shims for transcribefile.+//+// cosmocc's <math.h> declares the llround family but the toolchain ships+// only the lround family (lround/lroundf/lroundl are in libcosmo.a;+// llround/llroundf/llroundl are not). transcribe.cpp uses std::llround in+// a few timestamp computations, which libc++ forwards to ::llround.+//+// On every cosmopolitan target (x86-64 and aarch64) the ABI is LP64, so+// `long` and `long long` are both 64-bit and the llround family is exactly+// equivalent to the lround family. Define the missing symbols in terms of+// the ones that exist.++#include <math.h>++long long llround(double x) { return lround(x); }+long long llroundf(float x) { return lroundf(x); }+long long llroundl(long double x) { return lroundl(x); }diff --git a/transcribefile/main.cpp b/transcribefile/main.cppnew file mode 100644index 00000000..38526446--- /dev/null+++ b/transcribefile/main.cpp@@ -0,0 +1,54 @@+// -*- mode:c++;indent-tabs-mode:nil;c-basic-offset:4;coding:utf-8 -*-+// vi: set et ft=cpp ts=4 sts=4 sw=4 fenc=utf-8 :vi+//+// transcribefile entry point.+//+// Wraps transcribe.cpp's example CLI (transcribe_cli_main, exposed when+// examples/cli/main.cpp is built with -DTRANSCRIBEFILE) with the+// llamafile-style conveniences: a crash handler and, crucially, loading+// default arguments from the executable's own zip store at /zip/.args.+//+// That last bit is what makes a self-contained `foo.transcribefile`+// possible: zipalign a GGUF plus a .args file (e.g. containing+// `-m\n/zip/model.gguf`) into the executable and it runs with no+// command-line arguments. Models can still be loaded from disk, or from+// the zip explicitly via `-m /zip/<name>.gguf`.++#include <cosmo.h>+#include <stdio.h>+#include <string.h>++// Defined in transcribe.cpp/examples/cli/main.cpp, compiled with+// -DTRANSCRIBEFILE (which renames its main() to transcribe_cli_main() and+// drops the standalone main()). C++ linkage — both sides are C++.+int transcribe_cli_main(int argc, char ** argv);++#ifndef TRANSCRIBEFILE_VERSION_STRING+#define TRANSCRIBEFILE_VERSION_STRING "0.0.0-dev"+#endif++static bool has_flag(char ** argv, const char * flag) {+ for (char ** p = argv + 1; p && *p; ++p) {+ if (!strcmp(*p, flag)) {+ return true;+ }+ }+ return false;+}++int main(int argc, char ** argv) {+ // Symbolized backtraces on crash (cosmopolitan).+ ShowCrashReports();++ // Answer --version before touching args or the zip store.+ if (has_flag(argv, "--version")) {+ puts("transcribefile v" TRANSCRIBEFILE_VERSION_STRING);+ return 0;+ }++ // Merge default arguments embedded at /zip/.args (if present) with the+ // user's argv. No-op for a bare executable with no bundled .args.+ argc = cosmo_args("/zip/.args", &argv);++ return transcribe_cli_main(argc, argv);+}