A local, API-free command-line transcription tool for Cohere Transcribe.
cohere-transcribe transcribes local audio files entirely on your machine. It
does not call the Cohere API. On first run it downloads the required model
artifacts from Hugging Face, caches them locally, and runs inference locally
with ONNX Runtime. Japanese (ja) is the default
language.
cohere-transcribe speech.wav --language ja --output transcript.txt
curl for downloads. No Python required.curl on PATH (used to download model artifacts)git clone <this-repo> cohere-transcribe
cd cohere-transcribe
# Configure + build WITH the ONNX Runtime inference backend.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCOHERE_ENABLE_ONNX=ON
cmake --build build -j
# The binary is at build/cohere-transcribe
./build/cohere-transcribe --version
By default (-DCOHERE_ENABLE_ONNX=ON) the build looks for ONNX Runtime in this
order:
-DONNXRUNTIME_ROOT_DIR=/path/to/onnxruntime (an extracted prebuilt package)find_library)FetchContentIf you only want to build/test the non-inference parts (CLI, audio, tokenizer, downloader), configure without ONNX Runtime — the inference backend becomes a clear-error stub:
cmake -S . -B build # COHERE_ENABLE_ONNX defaults to OFF
cmake --build build -j
cmake --install build --prefix /usr/local # installs bin/cohere-transcribe
# Transcribe to stdout (Japanese by default)
cohere-transcribe speech.wav
# Specify language and write to a file
cohere-transcribe speech.wav --language ja --output transcript.txt
# Short flags
cohere-transcribe speech.wav -l ja
# JSON output
cohere-transcribe speech.wav -l ja --json
# Pre-download model artifacts and exit
cohere-transcribe --download-only
# Use a custom model cache directory
cohere-transcribe speech.wav --model-dir ~/.cache/cohere-transcribe-cli/models
# Fail (do not download) if model artifacts are missing
cohere-transcribe --no-download speech.wav
| Option | Description |
|---|---|
-l, --language <code> | Language code (default: ja) |
-o, --output <file> | Write transcript to a file instead of stdout |
--json | Emit JSON instead of plain text |
--model-dir <path> | Model cache directory |
--download-only | Download model artifacts and exit |
--no-download | Do not download; fail if artifacts are missing |
--threads <n> | Number of CPU inference threads (default: auto) |
--verbose | Detailed logs on stderr |
--version | Print version and exit |
-h, --help | Show help and exit |
The Cohere Transcribe model may be gated (you must accept its terms) or the ONNX conversion may live in a private repo. To authenticate downloads:
Visit the model page on Hugging Face and accept the terms / request access.
Create a token at https://huggingface.co/settings/tokens.
Export it before running:
export HF_TOKEN=hf_xxxxxxxxxxxxxxxxxxxx
cohere-transcribe --download-only
If the download requires login or terms acceptance, the tool prints a clear
message and exits with a dedicated exit code (6), rather than failing opaquely.
The base model is CohereLabs/cohere-transcribe-03-2026, but the ONNX int8
artifacts (cohere-encoder.int8.onnx, etc.) come from an ONNX conversion. Point
the downloader at whichever repo hosts them:
export COHERE_TRANSCRIBE_HF_REPO=your-org/cohere-transcribe-onnx-int8
export COHERE_TRANSCRIBE_HF_REVISION=main # optional, defaults to main
~/.cache/cohere-transcribe-cli/models.../models/cohere-transcribe-onnx-int8/cohere-encoder.int8.onnxcohere-encoder.int8.onnx.datacohere-decoder.int8.onnxtokens.txtOn startup the tool checks whether all required files exist with non-zero size:
--no-download is not set, it downloads them from
Hugging Face (HTTPS via curl).--no-download is set, it fails with exit code 4.By default a fresh download is started each run (any stale .part is discarded)
so a partial left by a previous run of a different revision can't be silently
appended to. To enable cross-invocation resume for large files, export
COHERE_TRANSCRIBE_RESUME=1; within a single run, curl --retry already resumes
transient network failures.
Override the cache location with --model-dir (tilde ~ is expanded).
Plain text (default) — just the transcript:
文字起こし結果...
JSON (--json):
{
"language": "ja",
"text": "...",
"model": "cohere-transcribe-03-2026",
"backend": "onnx",
"duration_sec": 0.0
}
| Code | Meaning |
|---|---|
0 | Success |
1 | Generic error |
2 | Usage / command-line error |
3 | Audio read / decode error |
4 | Required model files missing and download disabled |
5 | Download / network / IO failure |
6 | Hugging Face login or terms acceptance required |
7 | Backend / inference failure |
8 | Tokenizer (tokens.txt) missing or malformed |
Module boundaries (src/):
| File | Responsibility |
|---|---|
main.cpp | Orchestration and top-level error handling |
cli.cpp | Argument parsing and usage/version text |
hf_downloader.cpp | Hugging Face artifact download (resume, auth) |
audio_loader.cpp | WAV decoding (PCM / IEEE float) |
audio_resampler.cpp | Mono downmix + 16 kHz resampling |
tokenizer.cpp | tokens.txt loading and greedy token decoding |
asr_backend.hpp | Backend interface (AsrBackend) + factory |
onnx_backend.cpp | ONNX Runtime backend (features + encoder/decoder) |
decoder.cpp | Greedy decoding + argmax utilities |
transcript_writer.cpp | Plain-text / JSON output |
paths.cpp | Model cache path resolution |
The backend is abstracted behind AsrBackend:
class AsrBackend {
public:
virtual ~AsrBackend() = default;
virtual std::string transcribe(
const std::vector<float>& mono_pcm_16khz,
const std::string& language,
int max_new_tokens) = 0;
};
This lets a GGUF / CrispASR (or other) backend be added later without changing the CLI, audio, tokenizer, or download layers.
--language.max_new_tokens; chunking is planned (see roadmap).COHERE_ENC_INPUT, COHERE_ENC_OUTPUT, COHERE_DEC_IDS,
COHERE_DEC_HIDDEN, COHERE_DEC_MASK, and COHERE_DEC_LOGITS. The decoder is
run without a KV cache; an export that requires KV-cache inputs is rejected
early with a clear message.audio_loader.hpp).AsrBackend implementation.brew install cohere-transcribe.# Configure with tests (on by default) and build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
# Run the test suite
cd build && ctest --output-on-failure
Unit tests cover CLI parsing, tokenizer loading/decoding, model cache path
resolution, WAV loading, and greedy decoding. An integration test drives the
built binary end-to-end for the paths that don't require the model
(--version, --help, usage errors, and --no-download with a missing model).
2 commits
C++
90.0%
CMake
10.0%
A local, API-free command-line transcription tool for Cohere Transcribe.
cohere-transcribe transcribes local audio files entirely on your machine. It
does not call the Cohere API. On first run it downloads the required model
artifacts from Hugging Face, caches them locally, and runs inference locally
with ONNX Runtime. Japanese (ja) is the default
language.
cohere-transcribe speech.wav --language ja --output transcript.txt
curl for downloads. No Python required.curl on PATH (used to download model artifacts)git clone <this-repo> cohere-transcribe
cd cohere-transcribe
# Configure + build WITH the ONNX Runtime inference backend.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCOHERE_ENABLE_ONNX=ON
cmake --build build -j
# The binary is at build/cohere-transcribe
./build/cohere-transcribe --version
By default (-DCOHERE_ENABLE_ONNX=ON) the build looks for ONNX Runtime in this
order:
-DONNXRUNTIME_ROOT_DIR=/path/to/onnxruntime (an extracted prebuilt package)find_library)FetchContentIf you only want to build/test the non-inference parts (CLI, audio, tokenizer, downloader), configure without ONNX Runtime — the inference backend becomes a clear-error stub:
cmake -S . -B build # COHERE_ENABLE_ONNX defaults to OFF
cmake --build build -j
cmake --install build --prefix /usr/local # installs bin/cohere-transcribe
# Transcribe to stdout (Japanese by default)
cohere-transcribe speech.wav
# Specify language and write to a file
cohere-transcribe speech.wav --language ja --output transcript.txt
# Short flags
cohere-transcribe speech.wav -l ja
# JSON output
cohere-transcribe speech.wav -l ja --json
# Pre-download model artifacts and exit
cohere-transcribe --download-only
# Use a custom model cache directory
cohere-transcribe speech.wav --model-dir ~/.cache/cohere-transcribe-cli/models
# Fail (do not download) if model artifacts are missing
cohere-transcribe --no-download speech.wav
| Option | Description |
|---|---|
-l, --language <code> | Language code (default: ja) |
-o, --output <file> | Write transcript to a file instead of stdout |
--json | Emit JSON instead of plain text |
--model-dir <path> | Model cache directory |
--download-only | Download model artifacts and exit |
--no-download | Do not download; fail if artifacts are missing |
--threads <n> | Number of CPU inference threads (default: auto) |
--verbose | Detailed logs on stderr |
--version | Print version and exit |
-h, --help | Show help and exit |
The Cohere Transcribe model may be gated (you must accept its terms) or the ONNX conversion may live in a private repo. To authenticate downloads:
Visit the model page on Hugging Face and accept the terms / request access.
Create a token at https://huggingface.co/settings/tokens.
Export it before running:
export HF_TOKEN=hf_xxxxxxxxxxxxxxxxxxxx
cohere-transcribe --download-only
If the download requires login or terms acceptance, the tool prints a clear
message and exits with a dedicated exit code (6), rather than failing opaquely.
The base model is CohereLabs/cohere-transcribe-03-2026, but the ONNX int8
artifacts (cohere-encoder.int8.onnx, etc.) come from an ONNX conversion. Point
the downloader at whichever repo hosts them:
export COHERE_TRANSCRIBE_HF_REPO=your-org/cohere-transcribe-onnx-int8
export COHERE_TRANSCRIBE_HF_REVISION=main # optional, defaults to main
~/.cache/cohere-transcribe-cli/models.../models/cohere-transcribe-onnx-int8/cohere-encoder.int8.onnxcohere-encoder.int8.onnx.datacohere-decoder.int8.onnxtokens.txtOn startup the tool checks whether all required files exist with non-zero size:
--no-download is not set, it downloads them from
Hugging Face (HTTPS via curl).--no-download is set, it fails with exit code 4.By default a fresh download is started each run (any stale .part is discarded)
so a partial left by a previous run of a different revision can't be silently
appended to. To enable cross-invocation resume for large files, export
COHERE_TRANSCRIBE_RESUME=1; within a single run, curl --retry already resumes
transient network failures.
Override the cache location with --model-dir (tilde ~ is expanded).
Plain text (default) — just the transcript:
文字起こし結果...
JSON (--json):
{
"language": "ja",
"text": "...",
"model": "cohere-transcribe-03-2026",
"backend": "onnx",
"duration_sec": 0.0
}
| Code | Meaning |
|---|---|
0 | Success |
1 | Generic error |
2 | Usage / command-line error |
3 | Audio read / decode error |
4 | Required model files missing and download disabled |
5 | Download / network / IO failure |
6 | Hugging Face login or terms acceptance required |
7 | Backend / inference failure |
8 | Tokenizer (tokens.txt) missing or malformed |
Module boundaries (src/):
| File | Responsibility |
|---|---|
main.cpp | Orchestration and top-level error handling |
cli.cpp | Argument parsing and usage/version text |
hf_downloader.cpp | Hugging Face artifact download (resume, auth) |
audio_loader.cpp | WAV decoding (PCM / IEEE float) |
audio_resampler.cpp | Mono downmix + 16 kHz resampling |
tokenizer.cpp | tokens.txt loading and greedy token decoding |
asr_backend.hpp | Backend interface (AsrBackend) + factory |
onnx_backend.cpp | ONNX Runtime backend (features + encoder/decoder) |
decoder.cpp | Greedy decoding + argmax utilities |
transcript_writer.cpp | Plain-text / JSON output |
paths.cpp | Model cache path resolution |
The backend is abstracted behind AsrBackend:
class AsrBackend {
public:
virtual ~AsrBackend() = default;
virtual std::string transcribe(
const std::vector<float>& mono_pcm_16khz,
const std::string& language,
int max_new_tokens) = 0;
};
This lets a GGUF / CrispASR (or other) backend be added later without changing the CLI, audio, tokenizer, or download layers.
--language.max_new_tokens; chunking is planned (see roadmap).COHERE_ENC_INPUT, COHERE_ENC_OUTPUT, COHERE_DEC_IDS,
COHERE_DEC_HIDDEN, COHERE_DEC_MASK, and COHERE_DEC_LOGITS. The decoder is
run without a KV cache; an export that requires KV-cache inputs is rejected
early with a clear message.audio_loader.hpp).AsrBackend implementation.brew install cohere-transcribe.# Configure with tests (on by default) and build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
# Run the test suite
cd build && ctest --output-on-failure
Unit tests cover CLI parsing, tokenizer loading/decoding, model cache path
resolution, WAV loading, and greedy decoding. An integration test drives the
built binary end-to-end for the paths that don't require the model
(--version, --help, usage errors, and --no-download with a missing model).
2 commits
C++
90.0%
CMake
10.0%