cohere-transcribe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +21 -0
- data/LICENSE.txt +201 -0
- data/NOTICE +5 -0
- data/README.md +265 -0
- data/THIRD_PARTY_NOTICES.md +67 -0
- data/exe/cohere-transcribe +8 -0
- data/exe/cohere-transcribe-doctor +8 -0
- data/ext/cohere_transcribe_native/CMakeLists.txt +262 -0
- data/ext/cohere_transcribe_native/README.md +26 -0
- data/ext/cohere_transcribe_native/audio_abi.cpp +1416 -0
- data/ext/cohere_transcribe_native/audio_exports.macos +5 -0
- data/ext/cohere_transcribe_native/audio_exports.map +10 -0
- data/ext/cohere_transcribe_native/cohere_abi.cpp +1209 -0
- data/ext/cohere_transcribe_native/exports.macos +40 -0
- data/ext/cohere_transcribe_native/exports.map +45 -0
- data/ext/cohere_transcribe_native/extconf.rb +89 -0
- data/ext/cohere_transcribe_native/test/abi_smoke.rb +232 -0
- data/ext/cohere_transcribe_native/test/audio_matrix_smoke.cpp +121 -0
- data/ext/cohere_transcribe_native/test/audio_reliability_smoke.cpp +198 -0
- data/ext/cohere_transcribe_native/test/native_abi_reliability_smoke.cpp +186 -0
- data/ext/cohere_transcribe_native/test/native_batch_projection_probe.rb +81 -0
- data/ext/cohere_transcribe_native/test/native_cancellation_smoke.cpp +194 -0
- data/lib/cohere/transcribe/alignment/ATTRIBUTION.md +23 -0
- data/lib/cohere/transcribe/alignment/LICENSE.ctc-forced-aligner +407 -0
- data/lib/cohere/transcribe/alignment/LICENSE.torchaudio +25 -0
- data/lib/cohere/transcribe/alignment/LICENSE.uroman +26 -0
- data/lib/cohere/transcribe/alignment/aligner.rb +476 -0
- data/lib/cohere/transcribe/alignment/ctc.rb +224 -0
- data/lib/cohere/transcribe/alignment/text.rb +237 -0
- data/lib/cohere/transcribe/alignment/uroman_data.rb +4950 -0
- data/lib/cohere/transcribe/api.rb +173 -0
- data/lib/cohere/transcribe/asr/batching.rb +472 -0
- data/lib/cohere/transcribe/asr/failure_policy.rb +112 -0
- data/lib/cohere/transcribe/asr/native.rb +676 -0
- data/lib/cohere/transcribe/audio/ATTRIBUTION.md +8 -0
- data/lib/cohere/transcribe/audio/LICENSE.auditok +21 -0
- data/lib/cohere/transcribe/audio/decoder.rb +315 -0
- data/lib/cohere/transcribe/audio/ffmpeg_native.rb +248 -0
- data/lib/cohere/transcribe/audio/segmentation.rb +260 -0
- data/lib/cohere/transcribe/cli.rb +727 -0
- data/lib/cohere/transcribe/configuration.rb +282 -0
- data/lib/cohere/transcribe/constants.rb +14 -0
- data/lib/cohere/transcribe/dense_converter.rb +548 -0
- data/lib/cohere/transcribe/doctor.rb +576 -0
- data/lib/cohere/transcribe/errors.rb +57 -0
- data/lib/cohere/transcribe/gguf_writer.rb +268 -0
- data/lib/cohere/transcribe/hub.rb +436 -0
- data/lib/cohere/transcribe/input.rb +110 -0
- data/lib/cohere/transcribe/licenses/crispasr.txt +21 -0
- data/lib/cohere/transcribe/loader.rb +128 -0
- data/lib/cohere/transcribe/model_identity.rb +440 -0
- data/lib/cohere/transcribe/output/publication.rb +1118 -0
- data/lib/cohere/transcribe/output/rendering.rb +105 -0
- data/lib/cohere/transcribe/output/timing.rb +86 -0
- data/lib/cohere/transcribe/python_text.rb +70 -0
- data/lib/cohere/transcribe/pytorch_checkpoint.rb +1180 -0
- data/lib/cohere/transcribe/runtime/engine.rb +1676 -0
- data/lib/cohere/transcribe/runtime/model_provider.rb +390 -0
- data/lib/cohere/transcribe/runtime/precision.rb +57 -0
- data/lib/cohere/transcribe/runtime/preparation.rb +215 -0
- data/lib/cohere/transcribe/runtime/resources.rb +165 -0
- data/lib/cohere/transcribe/runtime/word_pipeline.rb +364 -0
- data/lib/cohere/transcribe/safetensors.rb +579 -0
- data/lib/cohere/transcribe/state/checkpoint.rb +224 -0
- data/lib/cohere/transcribe/state/contracts.rb +141 -0
- data/lib/cohere/transcribe/state/io.rb +727 -0
- data/lib/cohere/transcribe/state/locking.rb +211 -0
- data/lib/cohere/transcribe/state/manifest.rb +155 -0
- data/lib/cohere/transcribe/state.rb +7 -0
- data/lib/cohere/transcribe/types.rb +535 -0
- data/lib/cohere/transcribe/vad/ATTRIBUTION.md +14 -0
- data/lib/cohere/transcribe/vad/LICENSE.faster-whisper +21 -0
- data/lib/cohere/transcribe/vad/LICENSE.silero-vad +21 -0
- data/lib/cohere/transcribe/vad/silero.rb +344 -0
- data/lib/cohere/transcribe/vad/silero_vad_v6.onnx +0 -0
- data/lib/cohere/transcribe/vad/timestamps.rb +219 -0
- data/lib/cohere/transcribe/version.rb +7 -0
- data/lib/cohere/transcribe.rb +26 -0
- data/sig/cohere/transcribe.rbs +250 -0
- data/vendor/crispasr/AUTHORS +510 -0
- data/vendor/crispasr/LICENSE +21 -0
- data/vendor/crispasr/UPSTREAM.md +9 -0
- data/vendor/crispasr/VERSION +1 -0
- data/vendor/crispasr/ggml/AUTHORS +335 -0
- data/vendor/crispasr/ggml/CMakeLists.txt +512 -0
- data/vendor/crispasr/ggml/LICENSE +21 -0
- data/vendor/crispasr/ggml/README.md +49 -0
- data/vendor/crispasr/ggml/cmake/FindNCCL.cmake +36 -0
- data/vendor/crispasr/ggml/cmake/GitVars.cmake +22 -0
- data/vendor/crispasr/ggml/cmake/common.cmake +50 -0
- data/vendor/crispasr/ggml/cmake/ggml-config.cmake.in +191 -0
- data/vendor/crispasr/ggml/ggml.pc.in +10 -0
- data/vendor/crispasr/ggml/include/ggml-alloc.h +85 -0
- data/vendor/crispasr/ggml/include/ggml-backend.h +431 -0
- data/vendor/crispasr/ggml/include/ggml-blas.h +25 -0
- data/vendor/crispasr/ggml/include/ggml-cann.h +123 -0
- data/vendor/crispasr/ggml/include/ggml-cpp.h +39 -0
- data/vendor/crispasr/ggml/include/ggml-cpu.h +151 -0
- data/vendor/crispasr/ggml/include/ggml-cuda.h +50 -0
- data/vendor/crispasr/ggml/include/ggml-hexagon.h +19 -0
- data/vendor/crispasr/ggml/include/ggml-metal.h +61 -0
- data/vendor/crispasr/ggml/include/ggml-opencl.h +26 -0
- data/vendor/crispasr/ggml/include/ggml-openvino.h +37 -0
- data/vendor/crispasr/ggml/include/ggml-opt.h +256 -0
- data/vendor/crispasr/ggml/include/ggml-rpc.h +35 -0
- data/vendor/crispasr/ggml/include/ggml-sycl.h +49 -0
- data/vendor/crispasr/ggml/include/ggml-virtgpu.h +14 -0
- data/vendor/crispasr/ggml/include/ggml-vulkan.h +29 -0
- data/vendor/crispasr/ggml/include/ggml-webgpu.h +19 -0
- data/vendor/crispasr/ggml/include/ggml-zdnn.h +17 -0
- data/vendor/crispasr/ggml/include/ggml-zendnn.h +22 -0
- data/vendor/crispasr/ggml/include/ggml.h +2887 -0
- data/vendor/crispasr/ggml/include/gguf.h +204 -0
- data/vendor/crispasr/ggml/src/CMakeLists.txt +493 -0
- data/vendor/crispasr/ggml/src/ggml-alloc.c +1323 -0
- data/vendor/crispasr/ggml/src/ggml-backend-dl.cpp +48 -0
- data/vendor/crispasr/ggml/src/ggml-backend-dl.h +44 -0
- data/vendor/crispasr/ggml/src/ggml-backend-impl.h +275 -0
- data/vendor/crispasr/ggml/src/ggml-backend-meta.cpp +2145 -0
- data/vendor/crispasr/ggml/src/ggml-backend-reg.cpp +586 -0
- data/vendor/crispasr/ggml/src/ggml-backend.cpp +2437 -0
- data/vendor/crispasr/ggml/src/ggml-common.h +1900 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/CMakeLists.txt +718 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/amx.cpp +249 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/amx.h +8 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/common.h +115 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/mmq.cpp +2512 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/mmq.h +10 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp +98 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/quants.c +4244 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/repack.cpp +5156 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/loongarch/quants.c +2158 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/powerpc/quants.c +2304 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/cpu-feats.cpp +38 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/quants.c +4455 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/repack.cpp +1703 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/s390/cpu-feats.cpp +50 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/s390/quants.c +1465 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/wasm/quants.c +1220 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/quants.c +3970 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/repack.cpp +6407 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch-fallback.h +349 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/binary-ops.cpp +154 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/binary-ops.h +16 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +100 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/common.h +95 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu-impl.h +539 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu.c +3791 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu.cpp +703 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/hbm.cpp +55 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/hbm.h +8 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kernels.cpp +939 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kernels.h +90 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +1513 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kleidiai.h +17 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/llamafile/sgemm.cpp +4051 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/llamafile/sgemm.h +25 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ops.cpp +11662 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ops.h +121 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/quants.c +1288 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/quants.h +103 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/repack.cpp +4836 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/repack.h +245 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/simd-gemm.h +226 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/simd-mappings.h +1329 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime.cpp +1025 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime.h +13 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime1_kernels.cpp +3196 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime_kernels.h +26 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/traits.cpp +36 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/traits.h +38 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/unary-ops.cpp +336 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/unary-ops.h +35 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/vec.cpp +681 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/vec.h +1606 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/CMakeLists.txt +272 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/acc.cu +61 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/acc.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/add-id.cu +58 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/add-id.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/arange.cu +34 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/arange.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argmax.cu +91 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argmax.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argsort.cu +265 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argsort.cuh +19 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/binbcast.cu +534 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/binbcast.cuh +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/clamp.cu +45 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/clamp.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/common.cuh +1489 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/concat.cu +204 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/concat.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv-transpose-1d.cu +97 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv-transpose-1d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-transpose.cu +115 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-transpose.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d.cu +166 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/convert.cu +892 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/convert.cuh +66 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/count-equal.cu +64 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/count-equal.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cp-async.cuh +57 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cpy-utils.cuh +217 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cpy.cu +581 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cpy.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cross-entropy-loss.cu +177 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cross-entropy-loss.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cumsum.cu +307 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cumsum.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/dequantize.cuh +99 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diag.cu +77 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diag.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diagmask.cu +40 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diagmask.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-common.cuh +1212 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-mma-f16.cuh +1860 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-tile.cu +57 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-tile.cuh +1309 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-vec.cuh +600 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-wmma-f16.cu +696 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-wmma-f16.cuh +51 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn.cu +620 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fill.cu +37 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fill.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gated_delta_net.cu +273 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gated_delta_net.cuh +4 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/getrows.cu +332 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/getrows.cuh +15 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ggml-cuda.cu +5580 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gla.cu +93 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gla.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/im2col.cu +274 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/im2col.cuh +6 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mean.cu +75 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mean.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mma.cuh +1333 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmf.cu +191 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmf.cuh +908 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmid.cu +164 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmid.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmq.cu +372 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmq.cuh +4175 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvf.cu +862 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvf.cuh +14 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvq.cu +1161 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvq.cuh +16 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/norm.cu +756 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/norm.cuh +20 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-adamw.cu +78 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-adamw.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-sgd.cu +49 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-sgd.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/out-prod.cu +68 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/out-prod.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad.cu +106 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad_reflect_1d.cu +91 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad_reflect_1d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pool2d.cu +94 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pool2d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/quantize.cu +443 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/quantize.cuh +41 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/reduce_rows.cuh +39 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/roll.cu +67 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/roll.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/rope.cu +665 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/rope.cuh +9 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/scale.cu +34 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/scale.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set-rows.cu +330 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set-rows.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set.cu +39 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softcap.cu +34 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softcap.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softmax.cu +472 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softmax.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/solve_tri.cu +275 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/solve_tri.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-conv.cu +197 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-conv.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-scan.cu +342 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-scan.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sum.cu +41 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sum.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sumrows.cu +43 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sumrows.cuh +4 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_32.cu +6 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_32.cu +6 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_64-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq112-dv112.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq128-dv128.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq256-dv256.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq320-dv256.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq40-dv40.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq512-dv512.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq576-dv512.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq64-dv64.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq72-dv72.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq80-dv80.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq96-dv96.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_1.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_10.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_11.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_12.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_13.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_14.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_15.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_2.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_3.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_4.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_5.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_6.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_7.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_8.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_9.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq1_s.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_s.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xxs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_s.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_xxs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_nl.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_xs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-mxfp4.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-nvfp4.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q1_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q2_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q3_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_1.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_1.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q6_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q8_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/top-k.cu +95 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/top-k.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/topk-moe.cu +415 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/topk-moe.cuh +27 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tri.cu +136 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tri.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tsembd.cu +47 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tsembd.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/unary.cu +644 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/unary.cuh +116 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/upscale.cu +293 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/upscale.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vecdotq.cuh +1317 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vendors/cuda.h +28 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vendors/hip.h +306 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vendors/musa.h +148 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/wkv.cu +199 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/wkv.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-impl.h +783 -0
- data/vendor/crispasr/ggml/src/ggml-metal/CMakeLists.txt +124 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-common.cpp +457 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-common.h +52 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-context.h +41 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-context.m +778 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.cpp +2117 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.h +299 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.m +2093 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-impl.h +1267 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-ops.cpp +5023 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-ops.h +111 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal.cpp +954 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal.metal +11756 -0
- data/vendor/crispasr/ggml/src/ggml-opt.cpp +1094 -0
- data/vendor/crispasr/ggml/src/ggml-quants.c +5491 -0
- data/vendor/crispasr/ggml/src/ggml-quants.h +112 -0
- data/vendor/crispasr/ggml/src/ggml-threading.cpp +12 -0
- data/vendor/crispasr/ggml/src/ggml-threading.h +14 -0
- data/vendor/crispasr/ggml/src/ggml.c +7925 -0
- data/vendor/crispasr/ggml/src/ggml.cpp +26 -0
- data/vendor/crispasr/ggml/src/gguf.cpp +1556 -0
- data/vendor/crispasr/src/cohere-arch.h +137 -0
- data/vendor/crispasr/src/cohere.cpp +5642 -0
- data/vendor/crispasr/src/cohere.h +327 -0
- data/vendor/crispasr/src/cohere_batch_planner.h +82 -0
- data/vendor/crispasr/src/cohere_chunking.h +64 -0
- data/vendor/crispasr/src/cohere_decoder_batch_layout.h +60 -0
- data/vendor/crispasr/src/cohere_encoder_padded_layout.h +27 -0
- data/vendor/crispasr/src/cohere_frontend.cpp +189 -0
- data/vendor/crispasr/src/cohere_frontend.h +31 -0
- data/vendor/crispasr/src/cohere_ragged_controller.h +149 -0
- data/vendor/crispasr/src/cohere_token_renderer.h +181 -0
- data/vendor/crispasr/src/core/attention.h +924 -0
- data/vendor/crispasr/src/core/audio_chunking.h +97 -0
- data/vendor/crispasr/src/core/beam_decode.h +486 -0
- data/vendor/crispasr/src/core/cpu_ops.h +135 -0
- data/vendor/crispasr/src/core/gguf_loader.cpp +1021 -0
- data/vendor/crispasr/src/core/gguf_loader.h +216 -0
- data/vendor/crispasr/src/core/gpu_backend_pref.h +119 -0
- data/vendor/crispasr/src/core/mel.cpp +519 -0
- data/vendor/crispasr/src/core/mel.h +265 -0
- data/vendor/crispasr/src/core/ngram_loop_fix.h +173 -0
- data/vendor/crispasr/src/core/repetition_loop_guard.h +54 -0
- data/vendor/crispasr/src/crispasr_imatrix.cpp +255 -0
- data/vendor/crispasr/src/crispasr_imatrix.h +38 -0
- metadata +596 -0
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "optparse"
|
|
4
|
+
require_relative "version"
|
|
5
|
+
|
|
6
|
+
module Cohere
|
|
7
|
+
module Transcribe
|
|
8
|
+
# Command-line adapter for the dependency-light public API.
|
|
9
|
+
module CLI
|
|
10
|
+
DEFAULT_MODEL_ID = "CohereLabs/cohere-transcribe-arabic-07-2026"
|
|
11
|
+
OUTPUT_FORMATS = %w[txt srt vtt json].freeze
|
|
12
|
+
OUTPUT_PATH_DISPLAY_LIMIT = 20
|
|
13
|
+
FORMAT_ARGUMENT_SEPARATOR = "\u001F"
|
|
14
|
+
private_constant :FORMAT_ARGUMENT_SEPARATOR
|
|
15
|
+
VALUE_OPTIONS = %w[
|
|
16
|
+
model model-revision adapter adapter-revision language output-dir existing
|
|
17
|
+
device dtype audio-backend audio-memory-gb preprocess-workers vad vad-engine
|
|
18
|
+
vad-batch-size vad-block-frames vad-threads min-dur max-dur max-silence
|
|
19
|
+
energy-threshold vad-threshold min-silence-ms speech-pad-ms batch-size
|
|
20
|
+
batch-max-size batch-audio-seconds batch-vram-target max-new-tokens
|
|
21
|
+
max-retry-tokens truncation-policy alignment align-batch-size align-dtype
|
|
22
|
+
max-chars max-cue-dur max-gap profile-json
|
|
23
|
+
].freeze
|
|
24
|
+
REAL_VALUE_OPTIONS = %w[
|
|
25
|
+
audio-memory-gb min-dur max-dur max-silence energy-threshold vad-threshold
|
|
26
|
+
batch-audio-seconds batch-vram-target max-cue-dur max-gap
|
|
27
|
+
].freeze
|
|
28
|
+
INTEGER_VALUE_OPTIONS = %w[
|
|
29
|
+
preprocess-workers vad-batch-size vad-block-frames vad-threads min-silence-ms
|
|
30
|
+
speech-pad-ms batch-size batch-max-size max-new-tokens max-retry-tokens
|
|
31
|
+
align-batch-size max-chars
|
|
32
|
+
].freeze
|
|
33
|
+
FLAG_OPTIONS = %w[
|
|
34
|
+
recursive no-recursive pipeline-preparation no-pipeline-preparation vad-merge
|
|
35
|
+
no-vad-merge adaptive-batch no-adaptive-batch pin-memory no-pin-memory
|
|
36
|
+
stop-repetition-loops no-stop-repetition-loops text-only version help
|
|
37
|
+
].freeze
|
|
38
|
+
private_constant :VALUE_OPTIONS, :REAL_VALUE_OPTIONS, :INTEGER_VALUE_OPTIONS, :FLAG_OPTIONS
|
|
39
|
+
|
|
40
|
+
ParsedCommand = Data.define(:audio, :options)
|
|
41
|
+
|
|
42
|
+
class EarlyExit < StandardError
|
|
43
|
+
attr_reader :status
|
|
44
|
+
|
|
45
|
+
def initialize(status = 0)
|
|
46
|
+
@status = status
|
|
47
|
+
super()
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
module_function
|
|
52
|
+
|
|
53
|
+
def parse_args(argv = ARGV, out: $stdout)
|
|
54
|
+
values = default_values
|
|
55
|
+
state = { alignment: false, text_only: false }
|
|
56
|
+
raw_arguments = Array(argv).dup
|
|
57
|
+
preflight_mutually_exclusive_options!(raw_arguments)
|
|
58
|
+
preflight_reference_numeric_tokens!(raw_arguments)
|
|
59
|
+
preflight_ambiguous_long_options!(raw_arguments)
|
|
60
|
+
parser_arguments = defer_unknown_options_before_early_exit(raw_arguments)
|
|
61
|
+
arguments = normalize_formats_arguments(parser_arguments)
|
|
62
|
+
parser = option_parser(values, state, out: out)
|
|
63
|
+
parser.parse!(arguments)
|
|
64
|
+
enforce_reference_positional_order!(raw_arguments)
|
|
65
|
+
raise OptionParser::MissingArgument, "audio" if arguments.empty?
|
|
66
|
+
raise OptionParser::InvalidOption, "--text-only conflicts with --alignment" if state.values_at(:alignment, :text_only).all?
|
|
67
|
+
|
|
68
|
+
load_configuration_contract
|
|
69
|
+
values[:alignment] = "none" if values[:text_only]
|
|
70
|
+
text_mode = values[:alignment] == "none"
|
|
71
|
+
formats = values.delete(:formats)
|
|
72
|
+
formats = text_mode ? ["txt"] : %w[txt srt vtt] if formats.nil?
|
|
73
|
+
formats = formats.uniq
|
|
74
|
+
raise TranscriptionConfigurationError, "Plain-text mode supports only --formats txt" if text_mode && formats != ["txt"]
|
|
75
|
+
|
|
76
|
+
publication = PublicationOptions.new(
|
|
77
|
+
formats: formats,
|
|
78
|
+
output_dir: values.delete(:output_dir),
|
|
79
|
+
existing: values.delete(:existing),
|
|
80
|
+
profile_json: values.delete(:profile_json)
|
|
81
|
+
)
|
|
82
|
+
options = TranscriptionOptions.new(**values, publication: publication)
|
|
83
|
+
Configuration.validate!(options)
|
|
84
|
+
ParsedCommand.new(audio: arguments.map { |value| value.dup.freeze }.freeze, options: options)
|
|
85
|
+
rescue ArgumentError => e
|
|
86
|
+
raise if defined?(TranscriptionError) && e.is_a?(TranscriptionError)
|
|
87
|
+
|
|
88
|
+
raise OptionParser::InvalidArgument, e.message
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def main(argv = ARGV, out: $stdout, err: $stderr, transcriber: nil)
|
|
92
|
+
command = parse_args(argv, out: out)
|
|
93
|
+
load_public_api unless transcriber
|
|
94
|
+
unless transcriber || Cohere::Transcribe.respond_to?(:transcribe)
|
|
95
|
+
raise TranscriptionRuntimeError, "The public transcription runtime is unavailable"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
callable = transcriber || Cohere::Transcribe.method(:transcribe)
|
|
99
|
+
|
|
100
|
+
out.puts("\n[1/4] Validating inputs and outputs")
|
|
101
|
+
stage_two_printed = false
|
|
102
|
+
print_stage_two = lambda do
|
|
103
|
+
next if stage_two_printed
|
|
104
|
+
|
|
105
|
+
out.puts("\n[2/4] Loading ASR + preparing audio")
|
|
106
|
+
stage_two_printed = true
|
|
107
|
+
end
|
|
108
|
+
run = callable.call(
|
|
109
|
+
command.audio,
|
|
110
|
+
options: command.options,
|
|
111
|
+
progress: progress_reporter(out, before_first: print_stage_two),
|
|
112
|
+
raise_on_error: false
|
|
113
|
+
)
|
|
114
|
+
if all_skipped?(run)
|
|
115
|
+
run.skipped.each do |result|
|
|
116
|
+
out.puts(" skipping #{result.path}: verified output generation is complete")
|
|
117
|
+
end
|
|
118
|
+
out.puts(" All inputs were skipped; no model was loaded.")
|
|
119
|
+
run.errors.each { |error| out.puts(" [error] #{error}") }
|
|
120
|
+
command.options.publication.profile_json&.then { |path| out.puts(" #{path}") }
|
|
121
|
+
return run.ok? ? 0 : 1
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
print_stage_two.call
|
|
125
|
+
out.puts(
|
|
126
|
+
command.options.alignment == "word" ? "\n[3/4] Forced alignment + transactional outputs" : "\n[3/4] Transactional outputs"
|
|
127
|
+
)
|
|
128
|
+
out.puts("\n[4/4] Summary")
|
|
129
|
+
print_summary(run, out: out)
|
|
130
|
+
command.options.publication.profile_json&.then { |path| out.puts(" #{path}") }
|
|
131
|
+
run.ok? ? 0 : 1
|
|
132
|
+
rescue EarlyExit => e
|
|
133
|
+
e.status
|
|
134
|
+
rescue OptionParser::ParseError => e
|
|
135
|
+
err.puts(option_parser(default_values, {}, out: out))
|
|
136
|
+
err.puts("cohere-transcribe: error: #{e.message}")
|
|
137
|
+
2
|
|
138
|
+
rescue TranscriptionError => e
|
|
139
|
+
err.puts(e.message)
|
|
140
|
+
1
|
|
141
|
+
rescue Interrupt
|
|
142
|
+
out.puts(
|
|
143
|
+
"\n Interrupted; the active output commit was rolled back. " \
|
|
144
|
+
"Files completed earlier remain published."
|
|
145
|
+
)
|
|
146
|
+
130
|
|
147
|
+
rescue SignalException => e
|
|
148
|
+
raise unless e.signm == "SIGTERM"
|
|
149
|
+
|
|
150
|
+
out.puts(
|
|
151
|
+
"\n Termination requested; active work was cancelled and " \
|
|
152
|
+
"completed files remain published."
|
|
153
|
+
)
|
|
154
|
+
143
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Console-entry alias matching the reference package's outer entry point.
|
|
158
|
+
def cli(argv = ARGV, out: $stdout, err: $stderr, transcriber: nil)
|
|
159
|
+
main(argv, out: out, err: err, transcriber: transcriber)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def option_parser(values, state, out:)
|
|
163
|
+
OptionParser.new do |parser|
|
|
164
|
+
parser.banner = "Usage: cohere-transcribe [options] audio [audio ...]"
|
|
165
|
+
parser.separator("")
|
|
166
|
+
parser.separator("Batch Arabic/English transcription with optional timestamp alignment.")
|
|
167
|
+
parser.separator("")
|
|
168
|
+
|
|
169
|
+
parser.on("--model MODEL", "Hugging Face repository or local native Cohere ASR directory.") do |value|
|
|
170
|
+
values[:model] = value
|
|
171
|
+
end
|
|
172
|
+
parser.on("--model-revision REVISION", "Hub model commit, tag, or branch.") do |value|
|
|
173
|
+
values[:model_revision] = value
|
|
174
|
+
end
|
|
175
|
+
parser.on("--adapter ADAPTER", "Optional Hub repository or local LoRA adapter directory.") do |value|
|
|
176
|
+
values[:adapter] = value
|
|
177
|
+
end
|
|
178
|
+
parser.on("--adapter-revision REVISION", "Hub adapter commit, tag, or branch.") do |value|
|
|
179
|
+
values[:adapter_revision] = value
|
|
180
|
+
end
|
|
181
|
+
parser.on("--language LANGUAGE", String, %w[ar en], "Spoken language tag (ar or en).") do |value|
|
|
182
|
+
values[:language] = value
|
|
183
|
+
end
|
|
184
|
+
parser.on("--formats FORMAT [FORMAT ...]", String, "Outputs to write: txt, srt, vtt, json.") do |encoded|
|
|
185
|
+
value = encoded.split(FORMAT_ARGUMENT_SEPARATOR, -1)
|
|
186
|
+
unsupported = value - OUTPUT_FORMATS
|
|
187
|
+
unless unsupported.empty?
|
|
188
|
+
raise OptionParser::InvalidArgument,
|
|
189
|
+
"unsupported output format(s): #{unsupported.sort.join(", ")}"
|
|
190
|
+
end
|
|
191
|
+
values[:formats] = value
|
|
192
|
+
end
|
|
193
|
+
parser.on("--output-dir DIRECTORY", "Output root; preserve directory-relative structure.") do |value|
|
|
194
|
+
values[:output_dir] = value
|
|
195
|
+
end
|
|
196
|
+
parser.on("--recursive", "Recurse into input directories (default).") { values[:recursive] = true }
|
|
197
|
+
parser.on("--no-recursive", "Do not recurse into input directories.") { values[:recursive] = false }
|
|
198
|
+
parser.on("--existing POLICY", String, %w[error overwrite skip], "Existing outputs policy.") do |value|
|
|
199
|
+
values[:existing] = value
|
|
200
|
+
end
|
|
201
|
+
parser.on("--device DEVICE", String, %w[auto mps cuda cpu], "Inference device.") do |value|
|
|
202
|
+
values[:device] = value
|
|
203
|
+
end
|
|
204
|
+
parser.on("--dtype DTYPE", String, %w[auto bf16 fp16 fp32], "ASR model precision.") do |value|
|
|
205
|
+
values[:dtype] = value
|
|
206
|
+
end
|
|
207
|
+
parser.on(
|
|
208
|
+
"--audio-backend BACKEND",
|
|
209
|
+
String,
|
|
210
|
+
%w[auto torchcodec ffmpeg librosa],
|
|
211
|
+
"Audio decoder configuration."
|
|
212
|
+
) { |value| values[:audio_backend] = value }
|
|
213
|
+
parser.on("--audio-memory-gb GIB", String, "Decoded-PCM memory limit per file/group.") do |value|
|
|
214
|
+
values[:audio_memory_gb] = parse_reference_float(value)
|
|
215
|
+
end
|
|
216
|
+
parser.on("--preprocess-workers COUNT", String, "Concurrent audio decode workers.") do |value|
|
|
217
|
+
values[:preprocess_workers] = parse_reference_integer(value)
|
|
218
|
+
end
|
|
219
|
+
parser.on("--pipeline-preparation", "Overlap bounded preparation with ASR (default).") do
|
|
220
|
+
values[:pipeline_preparation] = true
|
|
221
|
+
end
|
|
222
|
+
parser.on("--no-pipeline-preparation", "Disable preparation/ASR overlap.") do
|
|
223
|
+
values[:pipeline_preparation] = false
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
parser.separator("")
|
|
227
|
+
parser.separator("Segmentation (VAD):")
|
|
228
|
+
parser.on("--vad MODE", String, %w[silero auditok none], "Segmentation policy.") do |value|
|
|
229
|
+
values[:vad] = value
|
|
230
|
+
end
|
|
231
|
+
parser.on("--vad-engine ENGINE", String, %w[auto torch onnx jit], "Silero runtime.") do |value|
|
|
232
|
+
values[:vad_engine] = value
|
|
233
|
+
end
|
|
234
|
+
parser.on("--vad-batch-size COUNT", String, "Maximum files per packed VAD call.") do |value|
|
|
235
|
+
values[:vad_batch_size] = parse_reference_integer(value)
|
|
236
|
+
end
|
|
237
|
+
parser.on("--vad-block-frames COUNT", String, "Maximum frames per packed VAD file.") do |value|
|
|
238
|
+
values[:vad_block_frames] = parse_reference_integer(value)
|
|
239
|
+
end
|
|
240
|
+
parser.on("--vad-threads COUNT", String, "Packed VAD CPU thread count.") do |value|
|
|
241
|
+
values[:vad_threads] = parse_reference_integer(value)
|
|
242
|
+
end
|
|
243
|
+
parser.on("--vad-merge", "Merge adjacent Silero speech spans.") { values[:vad_merge] = true }
|
|
244
|
+
parser.on("--no-vad-merge", "Do not merge adjacent Silero spans (default).") do
|
|
245
|
+
values[:vad_merge] = false
|
|
246
|
+
end
|
|
247
|
+
parser.on("--min-dur SECONDS", String, "Minimum speech duration.") do |value|
|
|
248
|
+
values[:min_dur] = parse_reference_float(value)
|
|
249
|
+
end
|
|
250
|
+
parser.on("--max-dur SECONDS", String, "Maximum segment/window duration.") do |value|
|
|
251
|
+
values[:max_dur] = parse_reference_float(value)
|
|
252
|
+
end
|
|
253
|
+
parser.on("--max-silence SECONDS", String, "Maximum Auditok internal silence.") do |value|
|
|
254
|
+
values[:max_silence] = parse_reference_float(value)
|
|
255
|
+
end
|
|
256
|
+
parser.on("--energy-threshold DB", String, "Auditok energy threshold.") do |value|
|
|
257
|
+
values[:energy_threshold] = parse_reference_float(value)
|
|
258
|
+
end
|
|
259
|
+
parser.on("--vad-threshold PROBABILITY", String, "Silero speech threshold.") do |value|
|
|
260
|
+
values[:vad_threshold] = parse_reference_float(value)
|
|
261
|
+
end
|
|
262
|
+
parser.on("--min-silence-ms MILLISECONDS", String, "Silero split silence.") do |value|
|
|
263
|
+
values[:min_silence_ms] = parse_reference_integer(value)
|
|
264
|
+
end
|
|
265
|
+
parser.on("--speech-pad-ms MILLISECONDS", String, "Silero speech padding.") do |value|
|
|
266
|
+
values[:speech_pad_ms] = parse_reference_integer(value)
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
parser.separator("")
|
|
270
|
+
parser.separator("Transcription:")
|
|
271
|
+
parser.on("--batch-size COUNT", String, "Initial ASR segment count.") do |value|
|
|
272
|
+
values[:batch_size] = parse_reference_integer(value)
|
|
273
|
+
end
|
|
274
|
+
parser.on("--batch-max-size COUNT", String, "Adaptive batch upper row cap.") do |value|
|
|
275
|
+
values[:batch_max_size] = parse_reference_integer(value)
|
|
276
|
+
end
|
|
277
|
+
parser.on("--batch-audio-seconds SECONDS", String, "Maximum padded audio per batch.") do |value|
|
|
278
|
+
values[:batch_audio_seconds] = parse_reference_float(value)
|
|
279
|
+
end
|
|
280
|
+
parser.on("--batch-vram-target FRACTION", String, "Adaptive batching VRAM target.") do |value|
|
|
281
|
+
values[:batch_vram_target] = parse_reference_float(value)
|
|
282
|
+
end
|
|
283
|
+
parser.on("--adaptive-batch", "Enable experimental adaptive batch growth.") do
|
|
284
|
+
values[:adaptive_batch] = true
|
|
285
|
+
end
|
|
286
|
+
parser.on("--no-adaptive-batch", "Disable adaptive growth (default).") do
|
|
287
|
+
values[:adaptive_batch] = false
|
|
288
|
+
end
|
|
289
|
+
parser.on("--pin-memory", "Compatibility flag; not applicable to native ggml.") do
|
|
290
|
+
values[:pin_memory] = true
|
|
291
|
+
end
|
|
292
|
+
parser.on("--no-pin-memory", "Leave native ggml host buffers unpinned (default).") do
|
|
293
|
+
values[:pin_memory] = false
|
|
294
|
+
end
|
|
295
|
+
parser.on("--max-new-tokens COUNT", String, "Initial decoder token limit.") do |value|
|
|
296
|
+
values[:max_new_tokens] = parse_reference_integer(value)
|
|
297
|
+
end
|
|
298
|
+
parser.on("--max-retry-tokens COUNT", String, "Automatic retry token limit.") do |value|
|
|
299
|
+
values[:max_retry_tokens] = parse_reference_integer(value)
|
|
300
|
+
end
|
|
301
|
+
parser.on("--truncation-policy POLICY", String, %w[retry warn], "Token-limit behavior.") do |value|
|
|
302
|
+
values[:truncation_policy] = value
|
|
303
|
+
end
|
|
304
|
+
parser.on("--stop-repetition-loops", "Stop conservative decoder repetition loops (default).") do
|
|
305
|
+
values[:stop_repetition_loops] = true
|
|
306
|
+
end
|
|
307
|
+
parser.on("--no-stop-repetition-loops", "Disable the repetition-loop guard.") do
|
|
308
|
+
values[:stop_repetition_loops] = false
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
parser.separator("")
|
|
312
|
+
parser.separator("Alignment and subtitle cues:")
|
|
313
|
+
parser.on("--alignment MODE", String, %w[word segment none], "Timestamp mode.") do |value|
|
|
314
|
+
state[:alignment] = true
|
|
315
|
+
values[:alignment] = value
|
|
316
|
+
end
|
|
317
|
+
parser.on("--text-only", "Alias for --alignment none.") do
|
|
318
|
+
state[:text_only] = true
|
|
319
|
+
values[:text_only] = true
|
|
320
|
+
end
|
|
321
|
+
parser.on("--align-batch-size COUNT", String, "Maximum alignment windows per batch.") do |value|
|
|
322
|
+
values[:align_batch_size] = parse_reference_integer(value)
|
|
323
|
+
end
|
|
324
|
+
parser.on("--align-dtype DTYPE", String, %w[fp32 fp16], "Alignment precision.") do |value|
|
|
325
|
+
values[:align_dtype] = value
|
|
326
|
+
end
|
|
327
|
+
parser.on("--max-chars COUNT", String, "Target subtitle cue length.") do |value|
|
|
328
|
+
values[:max_chars] = parse_reference_integer(value)
|
|
329
|
+
end
|
|
330
|
+
parser.on("--max-cue-dur SECONDS", String, "Target subtitle cue duration.") do |value|
|
|
331
|
+
values[:max_cue_dur] = parse_reference_float(value)
|
|
332
|
+
end
|
|
333
|
+
parser.on("--max-gap SECONDS", String, "Maximum inter-word cue gap.") do |value|
|
|
334
|
+
values[:max_gap] = parse_reference_float(value)
|
|
335
|
+
end
|
|
336
|
+
parser.on("--profile-json PATH", "Write performance telemetry as JSON.") do |value|
|
|
337
|
+
values[:profile_json] = value
|
|
338
|
+
end
|
|
339
|
+
parser.on("--version", "Show version and exit.") do
|
|
340
|
+
out.puts("cohere-transcribe #{VERSION}")
|
|
341
|
+
raise EarlyExit, 0
|
|
342
|
+
end
|
|
343
|
+
parser.on_tail("-h", "--help", "Show this help and exit.") do
|
|
344
|
+
out.puts(parser)
|
|
345
|
+
raise EarlyExit, 0
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def default_values
|
|
351
|
+
{
|
|
352
|
+
model: DEFAULT_MODEL_ID,
|
|
353
|
+
model_revision: nil,
|
|
354
|
+
adapter: nil,
|
|
355
|
+
adapter_revision: nil,
|
|
356
|
+
language: "ar",
|
|
357
|
+
formats: nil,
|
|
358
|
+
output_dir: nil,
|
|
359
|
+
recursive: true,
|
|
360
|
+
existing: "error",
|
|
361
|
+
device: "auto",
|
|
362
|
+
dtype: "auto",
|
|
363
|
+
audio_backend: "auto",
|
|
364
|
+
audio_memory_gb: 4.0,
|
|
365
|
+
preprocess_workers: nil,
|
|
366
|
+
pipeline_preparation: true,
|
|
367
|
+
vad: "silero",
|
|
368
|
+
vad_engine: "auto",
|
|
369
|
+
vad_batch_size: 16,
|
|
370
|
+
vad_block_frames: 512,
|
|
371
|
+
vad_threads: nil,
|
|
372
|
+
vad_merge: false,
|
|
373
|
+
min_dur: 0.5,
|
|
374
|
+
max_dur: 30.0,
|
|
375
|
+
max_silence: 0.6,
|
|
376
|
+
energy_threshold: 50.0,
|
|
377
|
+
vad_threshold: 0.5,
|
|
378
|
+
min_silence_ms: 300,
|
|
379
|
+
speech_pad_ms: 60,
|
|
380
|
+
batch_size: nil,
|
|
381
|
+
batch_max_size: nil,
|
|
382
|
+
batch_audio_seconds: nil,
|
|
383
|
+
batch_vram_target: 0.9,
|
|
384
|
+
adaptive_batch: false,
|
|
385
|
+
pin_memory: false,
|
|
386
|
+
max_new_tokens: 445,
|
|
387
|
+
max_retry_tokens: 896,
|
|
388
|
+
truncation_policy: "retry",
|
|
389
|
+
stop_repetition_loops: true,
|
|
390
|
+
alignment: "segment",
|
|
391
|
+
text_only: false,
|
|
392
|
+
align_batch_size: 4,
|
|
393
|
+
align_dtype: "fp32",
|
|
394
|
+
max_chars: 80,
|
|
395
|
+
max_cue_dur: 6.0,
|
|
396
|
+
max_gap: 0.6,
|
|
397
|
+
profile_json: nil
|
|
398
|
+
}
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
def normalize_formats_arguments(arguments)
|
|
402
|
+
normalized = []
|
|
403
|
+
index = 0
|
|
404
|
+
while index < arguments.length
|
|
405
|
+
argument = arguments[index]
|
|
406
|
+
if argument == "--"
|
|
407
|
+
normalized.concat(arguments[index..])
|
|
408
|
+
break
|
|
409
|
+
end
|
|
410
|
+
option = canonical_long_option(argument)
|
|
411
|
+
if argument == "-h" || %w[help version].include?(option)
|
|
412
|
+
normalized.concat(arguments[index..])
|
|
413
|
+
break
|
|
414
|
+
end
|
|
415
|
+
if option == "formats" && argument.include?("=")
|
|
416
|
+
validate_raw_formats!([argument.split("=", 2).last])
|
|
417
|
+
normalized << argument
|
|
418
|
+
index += 1
|
|
419
|
+
next
|
|
420
|
+
end
|
|
421
|
+
unless option == "formats" && !argument.include?("=")
|
|
422
|
+
normalized << argument
|
|
423
|
+
index += 1
|
|
424
|
+
next
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
formats = []
|
|
428
|
+
index += 1
|
|
429
|
+
while index < arguments.length && (!arguments[index].start_with?("-") || arguments[index] == "-")
|
|
430
|
+
formats << arguments[index]
|
|
431
|
+
index += 1
|
|
432
|
+
end
|
|
433
|
+
validate_raw_formats!(formats) unless formats.empty?
|
|
434
|
+
normalized << if formats.empty?
|
|
435
|
+
"--formats"
|
|
436
|
+
else
|
|
437
|
+
"--formats=#{formats.join(FORMAT_ARGUMENT_SEPARATOR)}"
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
normalized
|
|
441
|
+
end
|
|
442
|
+
private_class_method :normalize_formats_arguments
|
|
443
|
+
|
|
444
|
+
def validate_raw_formats!(formats)
|
|
445
|
+
unsupported = formats - OUTPUT_FORMATS
|
|
446
|
+
return if unsupported.empty?
|
|
447
|
+
|
|
448
|
+
raise OptionParser::InvalidArgument,
|
|
449
|
+
"unsupported output formats: #{unsupported.sort.join(", ")}"
|
|
450
|
+
end
|
|
451
|
+
private_class_method :validate_raw_formats!
|
|
452
|
+
|
|
453
|
+
def preflight_ambiguous_long_options!(arguments)
|
|
454
|
+
arguments.each do |argument|
|
|
455
|
+
break if argument == "--"
|
|
456
|
+
next unless argument.start_with?("--") && argument.length > 2
|
|
457
|
+
|
|
458
|
+
supplied = argument.delete_prefix("--").split("=", 2).first
|
|
459
|
+
names = VALUE_OPTIONS + FLAG_OPTIONS + ["formats"]
|
|
460
|
+
candidates = long_option_candidates(argument)
|
|
461
|
+
canonical = if names.include?(supplied)
|
|
462
|
+
supplied
|
|
463
|
+
elsif candidates.one?
|
|
464
|
+
candidates.first
|
|
465
|
+
end
|
|
466
|
+
break if %w[help version].include?(canonical)
|
|
467
|
+
next if names.include?(supplied)
|
|
468
|
+
|
|
469
|
+
raise OptionParser::AmbiguousOption, "--#{supplied}" if candidates.length > 1
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
private_class_method :preflight_ambiguous_long_options!
|
|
473
|
+
|
|
474
|
+
def preflight_reference_numeric_tokens!(arguments)
|
|
475
|
+
index = 0
|
|
476
|
+
while index < arguments.length
|
|
477
|
+
argument = arguments[index]
|
|
478
|
+
break if argument == "--"
|
|
479
|
+
|
|
480
|
+
option = canonical_long_option(argument)
|
|
481
|
+
return if argument == "-h" || %w[help version].include?(option)
|
|
482
|
+
|
|
483
|
+
if VALUE_OPTIONS.include?(option) && !argument.include?("=")
|
|
484
|
+
candidate = arguments[index + 1]
|
|
485
|
+
negative_value = candidate&.match?(/\A-\p{Nd}+\z|\A-\p{Nd}*\.\p{Nd}+\z/)
|
|
486
|
+
missing_value = candidate&.start_with?("-") && candidate != "-" && !negative_value
|
|
487
|
+
raise OptionParser::MissingArgument, "--#{option}" if missing_value
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
if option == "formats" && !argument.include?("=")
|
|
491
|
+
index += 1
|
|
492
|
+
index += 1 while index < arguments.length && (!arguments[index].start_with?("-") || arguments[index] == "-")
|
|
493
|
+
next
|
|
494
|
+
end
|
|
495
|
+
index += 1 if VALUE_OPTIONS.include?(option) && !argument.include?("=")
|
|
496
|
+
index += 1
|
|
497
|
+
end
|
|
498
|
+
end
|
|
499
|
+
private_class_method :preflight_reference_numeric_tokens!
|
|
500
|
+
|
|
501
|
+
def preflight_mutually_exclusive_options!(arguments)
|
|
502
|
+
alignment_seen = false
|
|
503
|
+
text_only_seen = false
|
|
504
|
+
index = 0
|
|
505
|
+
while index < arguments.length
|
|
506
|
+
argument = arguments[index]
|
|
507
|
+
break if argument == "--"
|
|
508
|
+
|
|
509
|
+
option = canonical_long_option(argument)
|
|
510
|
+
return if argument == "-h" || %w[help version].include?(option)
|
|
511
|
+
|
|
512
|
+
alignment_seen ||= option == "alignment"
|
|
513
|
+
text_only_seen ||= option == "text-only"
|
|
514
|
+
raise OptionParser::InvalidOption, "--text-only conflicts with --alignment" if alignment_seen && text_only_seen
|
|
515
|
+
|
|
516
|
+
index += 1
|
|
517
|
+
end
|
|
518
|
+
end
|
|
519
|
+
private_class_method :preflight_mutually_exclusive_options!
|
|
520
|
+
|
|
521
|
+
def defer_unknown_options_before_early_exit(arguments)
|
|
522
|
+
unknown_indices = []
|
|
523
|
+
early_index = nil
|
|
524
|
+
index = 0
|
|
525
|
+
while index < arguments.length
|
|
526
|
+
argument = arguments[index]
|
|
527
|
+
break if argument == "--"
|
|
528
|
+
|
|
529
|
+
option = canonical_long_option(argument)
|
|
530
|
+
if argument == "-h" || %w[help version].include?(option)
|
|
531
|
+
early_index = index
|
|
532
|
+
break
|
|
533
|
+
end
|
|
534
|
+
if argument.start_with?("--") && long_option_candidates(argument).empty?
|
|
535
|
+
unknown_indices << index
|
|
536
|
+
elsif argument.start_with?("-") && argument != "-" && !argument.start_with?("--")
|
|
537
|
+
unknown_indices << index
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
if option == "formats" && !argument.include?("=")
|
|
541
|
+
index += 1
|
|
542
|
+
index += 1 while index < arguments.length && (!arguments[index].start_with?("-") || arguments[index] == "-")
|
|
543
|
+
next
|
|
544
|
+
end
|
|
545
|
+
index += 1 if VALUE_OPTIONS.include?(option) && !argument.include?("=")
|
|
546
|
+
index += 1
|
|
547
|
+
end
|
|
548
|
+
return arguments.dup if early_index.nil? || unknown_indices.empty?
|
|
549
|
+
|
|
550
|
+
deferred = unknown_indices.map { |unknown_index| arguments[unknown_index] }
|
|
551
|
+
arguments.each_with_index.filter_map do |argument, argument_index|
|
|
552
|
+
next if unknown_indices.include?(argument_index)
|
|
553
|
+
|
|
554
|
+
argument_index == early_index ? [argument, *deferred] : argument
|
|
555
|
+
end.flatten
|
|
556
|
+
end
|
|
557
|
+
private_class_method :defer_unknown_options_before_early_exit
|
|
558
|
+
|
|
559
|
+
def parse_reference_float(value)
|
|
560
|
+
text = normalize_reference_numeric_text(value)
|
|
561
|
+
special = text.match?(/\A[+-]?(?:inf(?:inity)?|nan)\z/i)
|
|
562
|
+
digits = "[0-9](?:_?[0-9])*"
|
|
563
|
+
decimal = /\A[+-]?(?:(?:#{digits})(?:\.(?:#{digits})?)?|\.(?:#{digits}))(?:[eE][+-]?#{digits})?\z/
|
|
564
|
+
raise ArgumentError, "invalid float value: #{value.inspect}" unless special || text.match?(decimal)
|
|
565
|
+
|
|
566
|
+
case text.downcase
|
|
567
|
+
when "inf", "+inf", "infinity", "+infinity"
|
|
568
|
+
Float::INFINITY
|
|
569
|
+
when "-inf", "-infinity"
|
|
570
|
+
-Float::INFINITY
|
|
571
|
+
when "nan", "+nan", "-nan"
|
|
572
|
+
Float::NAN
|
|
573
|
+
else
|
|
574
|
+
Float(text.delete("_"))
|
|
575
|
+
end
|
|
576
|
+
end
|
|
577
|
+
private_class_method :parse_reference_float
|
|
578
|
+
|
|
579
|
+
def parse_reference_integer(value)
|
|
580
|
+
text = normalize_reference_numeric_text(value)
|
|
581
|
+
digits = "[0-9](?:_?[0-9])*"
|
|
582
|
+
raise ArgumentError, "invalid integer value: #{value.inspect}" unless text.match?(/\A[+-]?#{digits}\z/)
|
|
583
|
+
|
|
584
|
+
Integer(text.delete("_"), 10)
|
|
585
|
+
end
|
|
586
|
+
private_class_method :parse_reference_integer
|
|
587
|
+
|
|
588
|
+
def normalize_reference_numeric_text(value)
|
|
589
|
+
text = value.gsub(/\A[[:space:]]+|[[:space:]]+\z/, "")
|
|
590
|
+
text.each_char.map do |character|
|
|
591
|
+
next character unless character.match?(/\p{Nd}/)
|
|
592
|
+
|
|
593
|
+
codepoint = character.ord
|
|
594
|
+
first = codepoint
|
|
595
|
+
while first.positive?
|
|
596
|
+
previous = (first - 1).chr(Encoding::UTF_8)
|
|
597
|
+
break unless previous.match?(/\p{Nd}/)
|
|
598
|
+
|
|
599
|
+
first -= 1
|
|
600
|
+
end
|
|
601
|
+
((codepoint - first) % 10).to_s
|
|
602
|
+
end.join
|
|
603
|
+
end
|
|
604
|
+
private_class_method :normalize_reference_numeric_text
|
|
605
|
+
|
|
606
|
+
def enforce_reference_positional_order!(arguments)
|
|
607
|
+
positional_started = false
|
|
608
|
+
option_after_positional = false
|
|
609
|
+
index = 0
|
|
610
|
+
while index < arguments.length
|
|
611
|
+
argument = arguments[index]
|
|
612
|
+
if argument == "--"
|
|
613
|
+
detail = arguments[index + 1] || "--"
|
|
614
|
+
raise OptionParser::InvalidArgument, "unrecognized arguments: #{detail}" if option_after_positional
|
|
615
|
+
|
|
616
|
+
break
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
option = canonical_long_option(argument)
|
|
620
|
+
if option
|
|
621
|
+
option_after_positional ||= positional_started
|
|
622
|
+
if option == "formats" && !argument.include?("=")
|
|
623
|
+
index += 1
|
|
624
|
+
index += 1 while index < arguments.length && (!arguments[index].start_with?("-") || arguments[index] == "-")
|
|
625
|
+
next
|
|
626
|
+
end
|
|
627
|
+
index += 1 if VALUE_OPTIONS.include?(option) && !argument.include?("=")
|
|
628
|
+
elsif argument.start_with?("-") && argument != "-"
|
|
629
|
+
# A successful OptionParser pass means this is either the short help
|
|
630
|
+
# flag (which exits before here) or a literal positional dash.
|
|
631
|
+
else
|
|
632
|
+
raise OptionParser::InvalidArgument, "unrecognized arguments: #{argument}" if option_after_positional
|
|
633
|
+
|
|
634
|
+
positional_started = true
|
|
635
|
+
end
|
|
636
|
+
index += 1
|
|
637
|
+
end
|
|
638
|
+
end
|
|
639
|
+
private_class_method :enforce_reference_positional_order!
|
|
640
|
+
|
|
641
|
+
def canonical_long_option(argument)
|
|
642
|
+
return nil unless argument.start_with?("--") && argument.length > 2
|
|
643
|
+
|
|
644
|
+
supplied = argument.delete_prefix("--").split("=", 2).first
|
|
645
|
+
names = VALUE_OPTIONS + FLAG_OPTIONS + ["formats"]
|
|
646
|
+
return supplied if names.include?(supplied)
|
|
647
|
+
|
|
648
|
+
candidates = long_option_candidates(argument)
|
|
649
|
+
candidates.one? ? candidates.first : nil
|
|
650
|
+
end
|
|
651
|
+
private_class_method :canonical_long_option
|
|
652
|
+
|
|
653
|
+
def long_option_candidates(argument)
|
|
654
|
+
return [] unless argument.start_with?("--") && argument.length > 2
|
|
655
|
+
|
|
656
|
+
supplied = argument.delete_prefix("--").split("=", 2).first
|
|
657
|
+
(VALUE_OPTIONS + FLAG_OPTIONS + ["formats"]).select { |name| name.start_with?(supplied) }
|
|
658
|
+
end
|
|
659
|
+
private_class_method :long_option_candidates
|
|
660
|
+
|
|
661
|
+
def load_configuration_contract
|
|
662
|
+
require_relative "constants"
|
|
663
|
+
require_relative "errors"
|
|
664
|
+
require_relative "types"
|
|
665
|
+
require_relative "model_identity"
|
|
666
|
+
require_relative "configuration"
|
|
667
|
+
end
|
|
668
|
+
private_class_method :load_configuration_contract
|
|
669
|
+
|
|
670
|
+
def load_public_api
|
|
671
|
+
return if Cohere::Transcribe.respond_to?(:transcribe)
|
|
672
|
+
|
|
673
|
+
require "cohere/transcribe"
|
|
674
|
+
end
|
|
675
|
+
private_class_method :load_public_api
|
|
676
|
+
|
|
677
|
+
def progress_reporter(out, before_first: nil)
|
|
678
|
+
lambda do |event|
|
|
679
|
+
before_first&.call
|
|
680
|
+
if event.message
|
|
681
|
+
out.puts(event.message)
|
|
682
|
+
elsif !event.current.nil? && !event.total.nil? && event.current == event.total
|
|
683
|
+
out.puts(" #{event.stage}: #{event.current}/#{event.total}")
|
|
684
|
+
end
|
|
685
|
+
end
|
|
686
|
+
end
|
|
687
|
+
private_class_method :progress_reporter
|
|
688
|
+
|
|
689
|
+
def all_skipped?(run)
|
|
690
|
+
!run.results.empty? && run.skipped.length == run.results.length
|
|
691
|
+
end
|
|
692
|
+
private_class_method :all_skipped?
|
|
693
|
+
|
|
694
|
+
def print_summary(run, out:)
|
|
695
|
+
attempted = run.successful.length + run.failed.length
|
|
696
|
+
statistics = run.statistics
|
|
697
|
+
out.puts(
|
|
698
|
+
" #{run.successful.length}/#{attempted} files finished in " \
|
|
699
|
+
"#{format_duration(statistics.elapsed_seconds)} " \
|
|
700
|
+
"(RTFx #{format("%.1f", statistics.real_time_factor_x)})"
|
|
701
|
+
)
|
|
702
|
+
written = run.flat_map(&:outputs)
|
|
703
|
+
written.first(OUTPUT_PATH_DISPLAY_LIMIT).each { |path| out.puts(" #{path}") }
|
|
704
|
+
if written.length > OUTPUT_PATH_DISPLAY_LIMIT
|
|
705
|
+
out.puts(" ... and #{written.length - OUTPUT_PATH_DISPLAY_LIMIT} more output files")
|
|
706
|
+
end
|
|
707
|
+
unless run.failed.empty?
|
|
708
|
+
out.puts(" Failures:")
|
|
709
|
+
run.failed.each { |result| out.puts(" - #{result.path}: #{result.error}") }
|
|
710
|
+
end
|
|
711
|
+
run.errors.each { |error| out.puts(" [error] #{error}") }
|
|
712
|
+
end
|
|
713
|
+
private_class_method :print_summary
|
|
714
|
+
|
|
715
|
+
def format_duration(seconds)
|
|
716
|
+
rounded = [0, seconds.to_f.round].max
|
|
717
|
+
hours, remainder = rounded.divmod(3600)
|
|
718
|
+
minutes, remaining_seconds = remainder.divmod(60)
|
|
719
|
+
return format("%dh%02dm%02ds", hours, minutes, remaining_seconds) if hours.positive?
|
|
720
|
+
return format("%dm%02ds", minutes, remaining_seconds) if minutes.positive?
|
|
721
|
+
|
|
722
|
+
"#{remaining_seconds}s"
|
|
723
|
+
end
|
|
724
|
+
private_class_method :format_duration
|
|
725
|
+
end
|
|
726
|
+
end
|
|
727
|
+
end
|