Back to Moonshine

Options

docs/api/options.md

0.1.213.0 KB
Original Source

Options

Most Moonshine constructors accept a string-to-string options map (Python dict, moonshine_option_t array in C, name/value pairs elsewhere). Values are always strings at the ABI; language bindings may accept bools and numbers and stringify them for you.

Use this page as the catalog of keys. Class and C API pages link here instead of repeating full descriptions.

Shared options

These keys are recognized across multiple constructors. log_api_calls is stripped by a common parser before API-specific parsing; ort_providers and coreml_cache_dir apply wherever ONNX Runtime sessions are created.

KeyAccepted byDescription
log_api_callsTranscriber, TTS, G2P, speech-clip extract, and other C entry points that run common option parsingWhen true, log C API entry points and their arguments to stderr/console.
ort_providers (alias ort_provider)Transcriber, TTS, G2PComma-separated, ordered ONNX Runtime execution providers (for example CoreML,CPU). Names are case-insensitive; short forms (CPU, CoreML, NNAPI) or full names work. Unset means CPU-only (recommended). Mobile libraries ship CPU-only — requesting another provider there is an error. See execution providers.
coreml_cache_dirTranscriber, TTS, G2PDirectory for the CoreML compiled-model cache on macOS. Only used when CoreML is listed in ort_providers.
log_profilingTTS, G2PWhen true, log profiling information to the console.
g2p_rootTTS, G2P (and TTS dependency/voice listing)Asset root for G2P and TTS file layout. Empty means the process current working directory.
path_root / model_rootSame as g2p_rootAliases for g2p_root.
tts_rootTTS create / dependencies / voicesAlias for the asset root used when resolving TTS layout.

MicTranscriber .options() and AgentFlow .speech_options() forward into the native transcriber and TTS loaders respectively, so the keys below apply there too.

Speech to Text

Passed to Transcriber(..., options=…), MicTranscriber .options(), and moonshine_load_transcriber_from_files() / _from_memory_files() / deprecated _from_memory().

KeyDefaultDescription
skip_transcriptionfalseWhen true, run VAD/segmentation only (no STT). Use each line's audio buffer for further processing.
max_tokens_per_second6.5Truncate decoder loops when token rate looks pathological. Use about 13.0 for many non-Latin languages.
use_speculative_decodingtrueStreaming: verify the previous hypothesis and continue from the first mismatch. False falls back to greedy redecode from BOS.
keyterms(none)Comma-separated bias terms (streaming architectures only). See Domain Customization. Can also be set at runtime with set_keyterms / moonshine_transcriber_set_keyterms().
keyterm_boost2.0Strength of key-term biasing. Raise towards 4.0 to favor the list at the cost of the words around it, lower towards 1.0 for the reverse. Above 4.0 it stops working.
context(none)A passage of free-form text to pick key terms out of, for when you have context but not a list (streaming architectures only). Added to any keyterms. Can also be set at runtime with set_context / moonshine_transcriber_set_context().
context_max_terms200Most terms to take from context. Worth keeping modest: length is charged against the words you did not ask for.
transcription_interval0.5Seconds between automatic transcription passes (related to Python update_interval).
vad_threshold0.5VAD sensitivity. Lower → longer segments; higher → shorter chunks. 0 disables VAD (audio still chunked by vad_max_segment_duration).
vad_window_duration0.5Seconds of VAD scores to average when detecting speech.
vad_hop_size512VAD hop size in samples.
vad_look_behind_sample_count8192Samples to prepend when speech starts (compensates for averaged VAD lag), at 16 kHz.
vad_max_segment_duration15Maximum line length in seconds before a forced complete; threshold ramps down late in the segment.
save_input_wav_path(none)Folder path: write received audio as 16 kHz mono WAVs for debugging.
log_ort_runfalseLog ONNX Runtime inference runs and timings.
word_timestampsfalseFill each line's words array. Needs the attention decoder asset. Implied by identify_speakers.
identify_speakersfalseEnable diarization and speaker_spans. Needs diarization models (details).
diarization_model_dir(none)Directory with segmentation.ort and embedding.ort when constructing a transcriber directly.
diarization_cluster_cadence2.0Minimum seconds of new audio between re-clustering passes.
diarization_analyze_cadence0 (= model default 1.0)Seconds between segmentation/embedding model runs.
diarization_cluster_window_sec120Max recent history (seconds) for streaming VBx; 0 = unlimited. Batch/one-shot always uses full history.
return_audio_datatrueInclude per-line PCM in transcript results.
log_output_textfalseLog STT text to the console.
spelling_model_path(none)Path to a spelling-CNN .ort for MOONSHINE_FLAG_SPELLING_MODE.

Also accepts the shared keys log_api_calls, ort_providers, and coreml_cache_dir.

Text to Speech

Passed to TextToSpeech.options(), AgentFlow .speech_options(), and moonshine_create_tts_synthesizer_from_files() / _from_memory(). The same set is used (where relevant) by moonshine_get_tts_dependencies() and moonshine_get_tts_voices().

KeyDescription
voiceCatalog voice id. Prefix with kokoro_, piper_, or zipvoice_ to select the vocoder (for example kokoro_af_heart).
speedSpeaking-rate multiplier. Also the only per-call override honored by say() / synthesize() / moonshine_text_to_speech() / moonshine_phonemes_to_speech().
lang / languageLanguage tag when supplied via options (usually set by the constructor/language() setter instead).
kokoro_dirOverride Kokoro directory (model.ort + config.json under it).
kokoro_model / kokoro_model_onnxOverride Kokoro model path.
kokoro_config / kokoro_config_jsonOverride Kokoro config JSON path.
piper_onnx / piper_model_onnx / piper_modelOverride Piper model path (must be .ort).
piper_onnx_json / piper_model_json / piper_onnx_configOverride Piper JSON sidecar.
piper_voices_dir / voices_dirOverride Piper voices directory.
piper_voices_json_dir / voices_json_dirOverride Piper *.onnx.json directory.
normalize_audio / piper_normalize_audioPeak-normalize then apply gain/clip (default true).
output_volume / piper_output_volumeLinear gain after normalize (default 1).
piper_noise_scale / piper_noise_scale_overridePiper inference noise scale.
piper_noise_w / piper_noise_w_overridePiper inference noise_w.
zipvoice_clone_sample_rate / clone_sample_rateSample rate for caller-supplied zipvoice/clone_audio (default 24000).
zipvoice_clone_transcript / clone_transcriptTranscript for that clone clip.
zipvoice_model / zipvoice_model_namezipvoice vs distilled; sets sampling defaults.
zipvoice_distillUse distilled ZipVoice sampling defaults (default true).
zipvoice_num_step / num_stepDiffusion steps; <=0 → model default.
zipvoice_guidance_scale / guidance_scaleGuidance scale; <0 → model default.
zipvoice_t_shift / t_shiftTime-shift (default 0.5).
output / oDefault WAV path for CLI-style tooling (default out.wav).
engine / vocoder_engineAccepted but ignored (engine comes from the voice prefix).

Also accepts shared root aliases and ORT keys. Unknown TTS keys are forwarded to the G2P parser.

In-memory create uses file map keys (for example kokoro/model.ort, zipvoice/clone_audio, clone_asr/...) rather than option names — see the C API.

Grapheme to Phonemes

Passed to GraphemeToPhonemizer(..., options=…) and moonshine_create_grapheme_to_phonemizer_* / moonshine_get_g2p_dependencies().

Roots and runtime

KeyDescription
g2p_root / path_root / model_rootAsset root (see shared).
use_cudaEnable CUDA for G2P ORT sessions.
oov_onnx_overrideOverride English OOV model path/bytes.
oov_onnx_configOverride English OOV onnx-config.json UTF-8 text.
allow_builtin_g2p_dataDeprecated; ignored.

Also accepts ort_providers, coreml_cache_dir, log_profiling, and log_api_calls.

Lexicon and model path overrides

KeySets
english_dict_pathen_us/dict_filtered_heteronyms.tsv
german_dict_pathde/dict.tsv
french_dict_pathfr/dict.tsv
french_csv_dirfr (POS CSV directory)
dutch_dict_pathnl/dict.tsv
italian_dict_pathit/dict.tsv
russian_dict_pathru/dict.tsv
chinese_dict_pathzh_hans/dict.tsv
chinese_onnx_model_dirChinese RoBERTa UPOS bundle directory
korean_dict_pathko/dict.tsv
vietnamese_dict_pathvi/dict.tsv
japanese_dict_pathja/dict.tsv
japanese_onnx_model_dirJapanese tok-POS bundle directory
arabic_dict_pathar_msa/dict.tsv
arabic_onnx_model_dirArabic diacritizer bundle directory
hindi_dict_pathhi/dict.tsv
portuguese_dict_pathPortuguese lexicon override

Language feature flags

Bools controlling language-specific G2P behavior (defaults are generally true unless noted):

KeyNotes
spanish_with_stress, spanish_narrow_obstruentsSpanish
german_with_stress, german_vocoder_stressGerman
french_with_stress, french_liaison, french_liaison_optional, french_oov_rules, french_expand_cardinal_digitsFrench
dutch_with_stress, dutch_vocoder_stress, dutch_expand_cardinal_digitsDutch
italian_with_stress, italian_vocoder_stress, italian_expand_cardinal_digitsItalian
russian_with_stress, russian_vocoder_stressRussian
korean_expand_cardinal_digitsKorean
portuguese_with_stress, portuguese_vocoder_stress, portuguese_expand_cardinal_digits, portuguese_apply_pt_pt_final_eshPortuguese; portuguese_keep_syllable_dots defaults false
turkish_with_stress, turkish_expand_cardinal_digitsTurkish
ukrainian_with_stress, ukrainian_expand_cardinal_digitsUkrainian
hindi_with_stress, hindi_expand_cardinal_digitsHindi

TTS-only keys (voice, Piper/Kokoro paths, and so on) are ignored when listing G2P dependencies.

Embeddings

moonshine_create_embedding_model() takes model_variant as a dedicated argument (fp32, fp16, q8, q4 default, q4f16), not an options map. Create-from-memory accepts an options array but currently ignores it.

For moonshine_get_embedding_dependencies():

KeyDescription
variant (alias model_variant)Which quantized/float file to include in the download manifest.

Speech clip extract

Passed to moonshine_extract_speech_clip() (and the Python/VoiceClone capture path that wraps it):

KeyDefaultDescription
clip_duration_seconds4Length of the window to extract.
minimum_speech_seconds2Minimum speech in the window for is_complete.
vad_threshold0.5Speech probability threshold.
tail_pad_seconds0Extra audio after the VAD window.

Also accepts log_api_calls.

Download manifests

Speech to Text (moonshine_get_stt_dependencies())

You can pass the same option list you would use to load the model. Only these change which files are listed:

KeyDescription
model_archDecimal string of a MOONSHINE_MODEL_ARCH_* constant; omitted → language default.
word_timestampsInclude the attention decoder in the download.
include_spelling / spellingInclude the spelling-CNN group when published for the language.
spelling_model_pathNon-empty path → same as including the spelling group.

TTS / G2P dependency and voice listing

Use the TTS and G2P keys above (voice, g2p_root, and related). See moonshine_get_tts_dependencies(), moonshine_get_tts_voices(), and moonshine_get_g2p_dependencies() in the C API.