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,344 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../constants"
|
|
4
|
+
require_relative "../errors"
|
|
5
|
+
require_relative "timestamps"
|
|
6
|
+
|
|
7
|
+
module Cohere
|
|
8
|
+
module Transcribe
|
|
9
|
+
module VAD
|
|
10
|
+
class SileroBackendUnavailable < TranscriptionRuntimeError; end
|
|
11
|
+
|
|
12
|
+
# Thread-confined, bounded ONNX sequence runner for Silero VAD v6.
|
|
13
|
+
#
|
|
14
|
+
# The model consumes one row per 512-sample frame. Each row contains the
|
|
15
|
+
# preceding 64 waveform samples followed by the current frame. Recurrent
|
|
16
|
+
# h/c state and waveform context are carried across bounded temporal
|
|
17
|
+
# calls, while every new audio file starts from zero state.
|
|
18
|
+
class Silero
|
|
19
|
+
WINDOW_SAMPLES = Timestamps::WINDOW_SAMPLES
|
|
20
|
+
CONTEXT_SAMPLES = 64
|
|
21
|
+
MODEL_ROW_SAMPLES = WINDOW_SAMPLES + CONTEXT_SAMPLES
|
|
22
|
+
MAX_SEQUENCE_FRAMES = 256
|
|
23
|
+
DEFAULT_INTRA_OP_THREADS = 1
|
|
24
|
+
STATE_WIDTH = 128
|
|
25
|
+
MODEL_PATH = File.expand_path("silero_vad_v6.onnx", __dir__).freeze
|
|
26
|
+
ENGINE = "onnx"
|
|
27
|
+
PROVIDER = "CPUExecutionProvider"
|
|
28
|
+
SESSION_OPTIONS = {
|
|
29
|
+
providers: [PROVIDER].freeze,
|
|
30
|
+
inter_op_num_threads: 1,
|
|
31
|
+
intra_op_num_threads: 1,
|
|
32
|
+
enable_cpu_mem_arena: false,
|
|
33
|
+
log_severity_level: 4
|
|
34
|
+
}.freeze
|
|
35
|
+
|
|
36
|
+
Execution = Data.define(
|
|
37
|
+
:model_calls,
|
|
38
|
+
:valid_frames,
|
|
39
|
+
:padded_frames,
|
|
40
|
+
:max_files_per_call,
|
|
41
|
+
:effective_block_frames,
|
|
42
|
+
:model_load_seconds,
|
|
43
|
+
:inference_seconds,
|
|
44
|
+
:postprocess_seconds
|
|
45
|
+
) do
|
|
46
|
+
def initialize(model_calls:, valid_frames:, padded_frames:, max_files_per_call:, effective_block_frames:,
|
|
47
|
+
model_load_seconds: 0.0, inference_seconds: 0.0, postprocess_seconds: 0.0)
|
|
48
|
+
super
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
attr_reader :model_path, :block_frames, :intra_op_threads, :last_execution
|
|
53
|
+
|
|
54
|
+
def initialize(model_path: MODEL_PATH, session: nil, session_factory: nil,
|
|
55
|
+
block_frames: MAX_SEQUENCE_FRAMES, threads: DEFAULT_INTRA_OP_THREADS)
|
|
56
|
+
@model_path = File.expand_path(model_path.to_s).freeze
|
|
57
|
+
raise ArgumentError, "block_frames must be a positive integer" unless block_frames.is_a?(Integer) && block_frames.positive?
|
|
58
|
+
raise ArgumentError, "threads must be a positive integer" unless threads.is_a?(Integer) && threads.positive?
|
|
59
|
+
|
|
60
|
+
@block_frames = block_frames
|
|
61
|
+
@intra_op_threads = threads
|
|
62
|
+
@session = session
|
|
63
|
+
@session_factory = session_factory
|
|
64
|
+
@current_model_load_seconds = 0.0
|
|
65
|
+
@current_inference_seconds = 0.0
|
|
66
|
+
@last_execution = execution(model_calls: 0, valid_frames: 0)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def engine
|
|
70
|
+
ENGINE
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def provider
|
|
74
|
+
PROVIDER
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Match ONNX Runtime's execution-provider introspection. Thread counts
|
|
78
|
+
# belong to SessionOptions and are reported separately in the profile.
|
|
79
|
+
def provider_options
|
|
80
|
+
@provider_options ||= { PROVIDER => {}.freeze }.freeze
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def speech_probabilities(audio)
|
|
84
|
+
@current_model_load_seconds = 0.0
|
|
85
|
+
@current_inference_seconds = 0.0
|
|
86
|
+
audio_length = validate_mono_audio!(audio)
|
|
87
|
+
if audio_length.zero?
|
|
88
|
+
@last_execution = execution(model_calls: 0, valid_frames: 0)
|
|
89
|
+
return []
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
return speech_probabilities_numo(audio, audio_length) if numo_array?(audio)
|
|
93
|
+
|
|
94
|
+
hidden = zero_state
|
|
95
|
+
cell = zero_state
|
|
96
|
+
previous_context = Array.new(CONTEXT_SAMPLES, 0.0)
|
|
97
|
+
frame_count = (audio_length + WINDOW_SAMPLES - 1) / WINDOW_SAMPLES
|
|
98
|
+
outputs = []
|
|
99
|
+
|
|
100
|
+
model_calls = 0
|
|
101
|
+
(0...frame_count).step(block_frames) do |frame_start|
|
|
102
|
+
chunk_frames = [block_frames, frame_count - frame_start].min
|
|
103
|
+
frames = build_frames(audio, audio_length, frame_start, chunk_frames)
|
|
104
|
+
contexts = build_contexts(frames, previous_context)
|
|
105
|
+
previous_context = frames.last.last(CONTEXT_SAMPLES).dup
|
|
106
|
+
model_rows = contexts.zip(frames).map { |context, frame| context + frame }
|
|
107
|
+
|
|
108
|
+
probabilities, hidden, cell = run_model(model_rows, hidden, cell)
|
|
109
|
+
chunk_probabilities = one_dimensional_output(probabilities)
|
|
110
|
+
unless chunk_probabilities.length == chunk_frames
|
|
111
|
+
raise TranscriptionRuntimeError,
|
|
112
|
+
"Silero ONNX returned #{chunk_probabilities.length} probabilities " \
|
|
113
|
+
"for #{chunk_frames} frames"
|
|
114
|
+
end
|
|
115
|
+
outputs.concat(chunk_probabilities)
|
|
116
|
+
model_calls += 1
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
@last_execution = execution(model_calls: model_calls, valid_frames: frame_count)
|
|
120
|
+
outputs
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def speech_timestamps(
|
|
124
|
+
audio,
|
|
125
|
+
sampling_rate: SAMPLE_RATE,
|
|
126
|
+
threshold: 0.5,
|
|
127
|
+
min_speech_duration_ms: 250,
|
|
128
|
+
max_speech_duration_s: Float::INFINITY,
|
|
129
|
+
min_silence_duration_ms: 100,
|
|
130
|
+
speech_pad_ms: 30,
|
|
131
|
+
neg_threshold: nil,
|
|
132
|
+
min_silence_at_max_speech: 98,
|
|
133
|
+
use_max_poss_sil_at_max_speech: true,
|
|
134
|
+
cancel_check: nil
|
|
135
|
+
)
|
|
136
|
+
probabilities = speech_probabilities(audio)
|
|
137
|
+
started = monotonic
|
|
138
|
+
begin
|
|
139
|
+
Timestamps.from_probabilities(
|
|
140
|
+
audio.length,
|
|
141
|
+
probabilities,
|
|
142
|
+
sampling_rate: sampling_rate,
|
|
143
|
+
threshold: threshold,
|
|
144
|
+
min_speech_duration_ms: min_speech_duration_ms,
|
|
145
|
+
max_speech_duration_s: max_speech_duration_s,
|
|
146
|
+
min_silence_duration_ms: min_silence_duration_ms,
|
|
147
|
+
speech_pad_ms: speech_pad_ms,
|
|
148
|
+
neg_threshold: neg_threshold,
|
|
149
|
+
min_silence_at_max_speech: min_silence_at_max_speech,
|
|
150
|
+
use_max_poss_sil_at_max_speech: use_max_poss_sil_at_max_speech,
|
|
151
|
+
cancel_check: cancel_check
|
|
152
|
+
)
|
|
153
|
+
ensure
|
|
154
|
+
@last_execution = @last_execution.with(postprocess_seconds: monotonic - started)
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
private
|
|
159
|
+
|
|
160
|
+
def speech_probabilities_numo(audio, audio_length)
|
|
161
|
+
hidden = ::Numo::SFloat.zeros(1, 1, STATE_WIDTH)
|
|
162
|
+
cell = ::Numo::SFloat.zeros(1, 1, STATE_WIDTH)
|
|
163
|
+
previous_context = ::Numo::SFloat.zeros(CONTEXT_SAMPLES)
|
|
164
|
+
frame_count = (audio_length + WINDOW_SAMPLES - 1) / WINDOW_SAMPLES
|
|
165
|
+
outputs = []
|
|
166
|
+
|
|
167
|
+
model_calls = 0
|
|
168
|
+
(0...frame_count).step(block_frames) do |frame_start|
|
|
169
|
+
chunk_frames = [block_frames, frame_count - frame_start].min
|
|
170
|
+
sample_start = frame_start * WINDOW_SAMPLES
|
|
171
|
+
sample_end = [audio_length, (frame_start + chunk_frames) * WINDOW_SAMPLES].min
|
|
172
|
+
chunk_audio = audio[sample_start...sample_end].cast_to(::Numo::SFloat)
|
|
173
|
+
frames = ::Numo::SFloat.zeros(chunk_frames, WINDOW_SAMPLES)
|
|
174
|
+
full_frames, remainder = chunk_audio.size.divmod(WINDOW_SAMPLES)
|
|
175
|
+
if full_frames.positive?
|
|
176
|
+
frames[0...full_frames, true] =
|
|
177
|
+
chunk_audio[0...(full_frames * WINDOW_SAMPLES)].reshape(full_frames, WINDOW_SAMPLES)
|
|
178
|
+
end
|
|
179
|
+
frames[full_frames, 0...remainder] = chunk_audio[(full_frames * WINDOW_SAMPLES)...chunk_audio.size] if remainder.positive?
|
|
180
|
+
|
|
181
|
+
model_rows = ::Numo::SFloat.zeros(chunk_frames, MODEL_ROW_SAMPLES)
|
|
182
|
+
model_rows[0, 0...CONTEXT_SAMPLES] = previous_context
|
|
183
|
+
if chunk_frames > 1
|
|
184
|
+
model_rows[1...chunk_frames, 0...CONTEXT_SAMPLES] =
|
|
185
|
+
frames[0...(chunk_frames - 1), (WINDOW_SAMPLES - CONTEXT_SAMPLES)...WINDOW_SAMPLES]
|
|
186
|
+
end
|
|
187
|
+
model_rows[true, CONTEXT_SAMPLES...MODEL_ROW_SAMPLES] = frames
|
|
188
|
+
previous_context =
|
|
189
|
+
frames[chunk_frames - 1, (WINDOW_SAMPLES - CONTEXT_SAMPLES)...WINDOW_SAMPLES].dup
|
|
190
|
+
|
|
191
|
+
probabilities, hidden, cell = run_model(model_rows, hidden, cell, output_type: :numo)
|
|
192
|
+
chunk_probabilities = one_dimensional_output(probabilities)
|
|
193
|
+
unless chunk_probabilities.length == chunk_frames
|
|
194
|
+
raise TranscriptionRuntimeError,
|
|
195
|
+
"Silero ONNX returned #{chunk_probabilities.length} probabilities " \
|
|
196
|
+
"for #{chunk_frames} frames"
|
|
197
|
+
end
|
|
198
|
+
outputs.concat(chunk_probabilities)
|
|
199
|
+
model_calls += 1
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
@last_execution = execution(model_calls: model_calls, valid_frames: frame_count)
|
|
203
|
+
outputs
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def validate_mono_audio!(audio)
|
|
207
|
+
if audio.respond_to?(:ndim) && audio.ndim != 1
|
|
208
|
+
shape = audio.respond_to?(:shape) ? audio.shape.inspect : audio.ndim.to_s
|
|
209
|
+
raise ArgumentError, "Silero VAD expects mono audio, got shape #{shape}"
|
|
210
|
+
end
|
|
211
|
+
raise ArgumentError, "Silero VAD expects an indexable mono waveform" unless audio.respond_to?(:length) && audio.respond_to?(:[])
|
|
212
|
+
raise ArgumentError, "Silero VAD expects mono audio, got nested samples" if audio.is_a?(Array) && audio.any?(Array)
|
|
213
|
+
|
|
214
|
+
length = audio.length
|
|
215
|
+
raise ArgumentError, "Silero VAD expects a non-negative audio length" unless length.is_a?(Integer) && length >= 0
|
|
216
|
+
|
|
217
|
+
length
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def build_frames(audio, audio_length, frame_start, chunk_frames)
|
|
221
|
+
frames = Array.new(chunk_frames) { Array.new(WINDOW_SAMPLES, 0.0) }
|
|
222
|
+
sample_start = frame_start * WINDOW_SAMPLES
|
|
223
|
+
sample_end = [audio_length, (frame_start + chunk_frames) * WINDOW_SAMPLES].min
|
|
224
|
+
(sample_start...sample_end).each do |sample_index|
|
|
225
|
+
local_index = sample_index - sample_start
|
|
226
|
+
frame_index, within_frame = local_index.divmod(WINDOW_SAMPLES)
|
|
227
|
+
frames[frame_index][within_frame] = Float(audio[sample_index])
|
|
228
|
+
end
|
|
229
|
+
frames
|
|
230
|
+
rescue TypeError, ArgumentError => e
|
|
231
|
+
raise ArgumentError, "Silero VAD audio must contain real samples: #{e.message}"
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def build_contexts(frames, previous_context)
|
|
235
|
+
contexts = Array.new(frames.length) { Array.new(CONTEXT_SAMPLES, 0.0) }
|
|
236
|
+
contexts[0] = previous_context.dup
|
|
237
|
+
1.upto(frames.length - 1) do |index|
|
|
238
|
+
contexts[index] = frames[index - 1].last(CONTEXT_SAMPLES).dup
|
|
239
|
+
end
|
|
240
|
+
contexts
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def run_model(model_rows, hidden, cell, output_type: nil)
|
|
244
|
+
feed = {
|
|
245
|
+
"input" => model_rows,
|
|
246
|
+
"h" => hidden,
|
|
247
|
+
"c" => cell
|
|
248
|
+
}
|
|
249
|
+
active_session = session
|
|
250
|
+
started = monotonic
|
|
251
|
+
values = if output_type
|
|
252
|
+
active_session.run(nil, feed, output_type: output_type)
|
|
253
|
+
else
|
|
254
|
+
active_session.run(nil, feed)
|
|
255
|
+
end
|
|
256
|
+
unless values.is_a?(Array) && values.length == 3
|
|
257
|
+
raise TranscriptionRuntimeError, "Silero ONNX must return probabilities, hidden state, and cell state"
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
values
|
|
261
|
+
rescue StandardError => e
|
|
262
|
+
raise SileroBackendUnavailable, e.message if onnxruntime_error?(e)
|
|
263
|
+
|
|
264
|
+
raise
|
|
265
|
+
ensure
|
|
266
|
+
@current_inference_seconds += monotonic - started if started
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
def one_dimensional_output(values)
|
|
270
|
+
if values.respond_to?(:ndim) && values.ndim != 1
|
|
271
|
+
raise TranscriptionRuntimeError, "Silero ONNX returned a non-vector probability tensor"
|
|
272
|
+
end
|
|
273
|
+
raise TranscriptionRuntimeError, "Silero ONNX returned an invalid probability tensor" unless values.respond_to?(:to_a)
|
|
274
|
+
|
|
275
|
+
array = values.to_a
|
|
276
|
+
raise TranscriptionRuntimeError, "Silero ONNX returned a non-vector probability tensor" if array.any?(Array)
|
|
277
|
+
|
|
278
|
+
array.map { |value| Float(value) }
|
|
279
|
+
rescue TypeError, ArgumentError => e
|
|
280
|
+
raise TranscriptionRuntimeError, "Silero ONNX returned invalid probabilities: #{e.message}"
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def zero_state
|
|
284
|
+
[[Array.new(STATE_WIDTH, 0.0)]]
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def execution(model_calls:, valid_frames:)
|
|
288
|
+
Execution.new(
|
|
289
|
+
model_calls: model_calls,
|
|
290
|
+
valid_frames: valid_frames,
|
|
291
|
+
# The sequence graph receives one unpadded temporal stream. Only
|
|
292
|
+
# samples in the final 32 ms waveform frame can be zero-filled.
|
|
293
|
+
padded_frames: valid_frames,
|
|
294
|
+
max_files_per_call: model_calls.positive? ? 1 : 0,
|
|
295
|
+
effective_block_frames: block_frames,
|
|
296
|
+
model_load_seconds: @current_model_load_seconds,
|
|
297
|
+
inference_seconds: @current_inference_seconds,
|
|
298
|
+
postprocess_seconds: 0.0
|
|
299
|
+
)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def numo_array?(audio)
|
|
303
|
+
defined?(::Numo::NArray) && audio.is_a?(::Numo::NArray)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def session
|
|
307
|
+
return @session if @session
|
|
308
|
+
|
|
309
|
+
started = monotonic
|
|
310
|
+
@session = build_session
|
|
311
|
+
ensure
|
|
312
|
+
@current_model_load_seconds += monotonic - started if started
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
def build_session
|
|
316
|
+
raise SileroBackendUnavailable, "packaged Silero ONNX asset is missing: #{model_path}" unless File.file?(model_path)
|
|
317
|
+
|
|
318
|
+
return @session_factory.call(model_path, **session_options) if @session_factory
|
|
319
|
+
|
|
320
|
+
require "onnxruntime"
|
|
321
|
+
OnnxRuntime::InferenceSession.new(model_path, **session_options)
|
|
322
|
+
rescue LoadError, SystemCallError => e
|
|
323
|
+
raise SileroBackendUnavailable, "Silero ONNX backend is unavailable: #{e.message}"
|
|
324
|
+
rescue StandardError => e
|
|
325
|
+
raise SileroBackendUnavailable, e.message if onnxruntime_error?(e)
|
|
326
|
+
|
|
327
|
+
raise
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def onnxruntime_error?(error)
|
|
331
|
+
error.class.name.to_s.start_with?("OnnxRuntime::")
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def session_options
|
|
335
|
+
SESSION_OPTIONS.merge(intra_op_num_threads: intra_op_threads).freeze
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def monotonic
|
|
339
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
end
|
|
344
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cohere
|
|
4
|
+
module Transcribe
|
|
5
|
+
module VAD
|
|
6
|
+
# Silero 6.2.1's sample-domain timestamp state machine.
|
|
7
|
+
#
|
|
8
|
+
# Keeping this separate from the inference backend makes every Silero
|
|
9
|
+
# engine share exactly the same threshold, hysteresis, duration, and
|
|
10
|
+
# padding behavior.
|
|
11
|
+
module Timestamps
|
|
12
|
+
WINDOW_SAMPLES = 512
|
|
13
|
+
CANCELLATION_CHECK_FRAMES = 4_096
|
|
14
|
+
|
|
15
|
+
module_function
|
|
16
|
+
|
|
17
|
+
def from_probabilities(
|
|
18
|
+
audio_length_samples,
|
|
19
|
+
speech_probabilities,
|
|
20
|
+
sampling_rate: 16_000,
|
|
21
|
+
threshold: 0.5,
|
|
22
|
+
min_speech_duration_ms: 250,
|
|
23
|
+
max_speech_duration_s: Float::INFINITY,
|
|
24
|
+
min_silence_duration_ms: 100,
|
|
25
|
+
speech_pad_ms: 30,
|
|
26
|
+
neg_threshold: nil,
|
|
27
|
+
min_silence_at_max_speech: 98,
|
|
28
|
+
use_max_poss_sil_at_max_speech: true,
|
|
29
|
+
cancel_check: nil
|
|
30
|
+
)
|
|
31
|
+
check_cancellation(cancel_check)
|
|
32
|
+
raise ArgumentError, "The vectorized Silero v6 export requires 16 kHz audio" unless sampling_rate == 16_000
|
|
33
|
+
unless audio_length_samples.is_a?(Integer) && audio_length_samples >= 0
|
|
34
|
+
raise ArgumentError, "audio_length_samples must be a non-negative integer"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
speech_probs = one_dimensional_float32(speech_probabilities)
|
|
38
|
+
expected_frames = (audio_length_samples + WINDOW_SAMPLES - 1) / WINDOW_SAMPLES
|
|
39
|
+
unless speech_probs.length == expected_frames
|
|
40
|
+
raise ArgumentError,
|
|
41
|
+
"Silero probability count does not match the audio length: " \
|
|
42
|
+
"expected #{expected_frames}, got #{speech_probs.length}"
|
|
43
|
+
end
|
|
44
|
+
raise ArgumentError, "Silero probabilities contain non-finite values" unless speech_probs.all?(&:finite?)
|
|
45
|
+
unless speech_probs.all? { |probability| probability.between?(0.0, 1.0) }
|
|
46
|
+
raise ArgumentError, "Silero probabilities must be between zero and one"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
check_cancellation(cancel_check)
|
|
50
|
+
|
|
51
|
+
min_speech_samples = sampling_rate * min_speech_duration_ms / 1000.0
|
|
52
|
+
speech_pad_samples = sampling_rate * speech_pad_ms / 1000.0
|
|
53
|
+
max_speech_samples = (
|
|
54
|
+
(sampling_rate * max_speech_duration_s) - WINDOW_SAMPLES - (2 * speech_pad_samples)
|
|
55
|
+
)
|
|
56
|
+
min_silence_samples = sampling_rate * min_silence_duration_ms / 1000.0
|
|
57
|
+
min_silence_samples_at_max_speech = sampling_rate * min_silence_at_max_speech / 1000.0
|
|
58
|
+
# NumPy keeps scalar comparisons in the probability array's float32
|
|
59
|
+
# dtype. Coerce the comparison thresholds likewise so decimal values
|
|
60
|
+
# such as 0.01 and 0.35 do not move a frame across a boundary merely
|
|
61
|
+
# because Ruby Float is binary64.
|
|
62
|
+
positive_threshold = float32(threshold)
|
|
63
|
+
negative_threshold = float32(neg_threshold || [threshold - 0.15, 0.01].max)
|
|
64
|
+
|
|
65
|
+
triggered = false
|
|
66
|
+
speeches = []
|
|
67
|
+
current_speech = {}
|
|
68
|
+
temp_end = 0
|
|
69
|
+
prev_end = 0
|
|
70
|
+
next_start = 0
|
|
71
|
+
possible_ends = []
|
|
72
|
+
next_cancellation_check = CANCELLATION_CHECK_FRAMES
|
|
73
|
+
|
|
74
|
+
speech_probs.each_with_index do |speech_prob, index|
|
|
75
|
+
if index == next_cancellation_check
|
|
76
|
+
check_cancellation(cancel_check)
|
|
77
|
+
next_cancellation_check += CANCELLATION_CHECK_FRAMES
|
|
78
|
+
end
|
|
79
|
+
current_sample = WINDOW_SAMPLES * index
|
|
80
|
+
|
|
81
|
+
if speech_prob >= positive_threshold && temp_end.positive?
|
|
82
|
+
silence_duration = current_sample - temp_end
|
|
83
|
+
possible_ends << [temp_end, silence_duration] if silence_duration > min_silence_samples_at_max_speech
|
|
84
|
+
temp_end = 0
|
|
85
|
+
next_start = current_sample if next_start < prev_end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if speech_prob >= positive_threshold && !triggered
|
|
89
|
+
triggered = true
|
|
90
|
+
current_speech[:start] = current_sample
|
|
91
|
+
next
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
if triggered && current_sample - current_speech.fetch(:start) > max_speech_samples
|
|
95
|
+
if use_max_poss_sil_at_max_speech && !possible_ends.empty?
|
|
96
|
+
prev_end, silence_duration = possible_ends.max_by { |_end_sample, duration| duration }
|
|
97
|
+
current_speech[:end] = prev_end
|
|
98
|
+
speeches << current_speech
|
|
99
|
+
current_speech = {}
|
|
100
|
+
next_start = prev_end + silence_duration
|
|
101
|
+
if next_start < prev_end + current_sample
|
|
102
|
+
current_speech[:start] = next_start
|
|
103
|
+
else
|
|
104
|
+
triggered = false
|
|
105
|
+
end
|
|
106
|
+
prev_end = next_start = temp_end = 0
|
|
107
|
+
possible_ends = []
|
|
108
|
+
elsif prev_end.positive?
|
|
109
|
+
current_speech[:end] = prev_end
|
|
110
|
+
speeches << current_speech
|
|
111
|
+
current_speech = {}
|
|
112
|
+
if next_start < prev_end
|
|
113
|
+
triggered = false
|
|
114
|
+
else
|
|
115
|
+
current_speech[:start] = next_start
|
|
116
|
+
end
|
|
117
|
+
prev_end = next_start = temp_end = 0
|
|
118
|
+
possible_ends = []
|
|
119
|
+
else
|
|
120
|
+
current_speech[:end] = current_sample
|
|
121
|
+
speeches << current_speech
|
|
122
|
+
current_speech = {}
|
|
123
|
+
prev_end = next_start = temp_end = 0
|
|
124
|
+
triggered = false
|
|
125
|
+
possible_ends = []
|
|
126
|
+
next
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
next unless speech_prob < negative_threshold && triggered
|
|
131
|
+
|
|
132
|
+
temp_end = current_sample unless temp_end.positive?
|
|
133
|
+
current_silence_duration = current_sample - temp_end
|
|
134
|
+
if !use_max_poss_sil_at_max_speech &&
|
|
135
|
+
current_silence_duration > min_silence_samples_at_max_speech
|
|
136
|
+
prev_end = temp_end
|
|
137
|
+
end
|
|
138
|
+
next if current_silence_duration < min_silence_samples
|
|
139
|
+
|
|
140
|
+
current_speech[:end] = temp_end
|
|
141
|
+
speeches << current_speech if current_speech.fetch(:end) - current_speech.fetch(:start) > min_speech_samples
|
|
142
|
+
current_speech = {}
|
|
143
|
+
prev_end = next_start = temp_end = 0
|
|
144
|
+
triggered = false
|
|
145
|
+
possible_ends = []
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
check_cancellation(cancel_check)
|
|
149
|
+
if !current_speech.empty? &&
|
|
150
|
+
audio_length_samples - current_speech.fetch(:start) > min_speech_samples
|
|
151
|
+
current_speech[:end] = audio_length_samples
|
|
152
|
+
speeches << current_speech
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
pad_speeches!(speeches, audio_length_samples, speech_pad_samples, cancel_check)
|
|
156
|
+
check_cancellation(cancel_check)
|
|
157
|
+
speeches
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def one_dimensional_float32(values)
|
|
161
|
+
if values.respond_to?(:ndim) && values.ndim != 1
|
|
162
|
+
shape = values.respond_to?(:shape) ? values.shape.inspect : values.ndim.to_s
|
|
163
|
+
raise ArgumentError, "Silero probabilities must be one-dimensional, got #{shape}"
|
|
164
|
+
end
|
|
165
|
+
raise ArgumentError, "Silero probabilities must be one-dimensional" unless values.respond_to?(:to_a)
|
|
166
|
+
|
|
167
|
+
array = values.to_a
|
|
168
|
+
if array.any? { |value| value.is_a?(Array) || value.respond_to?(:ndim) }
|
|
169
|
+
raise ArgumentError, "Silero probabilities must be one-dimensional"
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
array.map { |value| float32(value) }
|
|
173
|
+
rescue TypeError, ArgumentError => e
|
|
174
|
+
raise e if e.message.start_with?("Silero probabilities")
|
|
175
|
+
|
|
176
|
+
raise ArgumentError, "Silero probabilities must contain real numbers: #{e.message}"
|
|
177
|
+
end
|
|
178
|
+
private_class_method :one_dimensional_float32
|
|
179
|
+
|
|
180
|
+
def float32(value)
|
|
181
|
+
[Float(value)].pack("f").unpack1("f")
|
|
182
|
+
end
|
|
183
|
+
private_class_method :float32
|
|
184
|
+
|
|
185
|
+
def pad_speeches!(speeches, audio_length_samples, speech_pad_samples, cancel_check)
|
|
186
|
+
next_cancellation_check = CANCELLATION_CHECK_FRAMES
|
|
187
|
+
speeches.each_with_index do |speech, index|
|
|
188
|
+
if index == next_cancellation_check
|
|
189
|
+
check_cancellation(cancel_check)
|
|
190
|
+
next_cancellation_check += CANCELLATION_CHECK_FRAMES
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
speech[:start] = [0, speech.fetch(:start) - speech_pad_samples].max.to_i if index.zero?
|
|
194
|
+
if index == speeches.length - 1
|
|
195
|
+
speech[:end] = [audio_length_samples, speech.fetch(:end) + speech_pad_samples].min.to_i
|
|
196
|
+
else
|
|
197
|
+
following = speeches[index + 1]
|
|
198
|
+
silence_duration = following.fetch(:start) - speech.fetch(:end)
|
|
199
|
+
if silence_duration < 2 * speech_pad_samples
|
|
200
|
+
half_silence = silence_duration.div(2)
|
|
201
|
+
speech[:end] += half_silence
|
|
202
|
+
following[:start] = [0, following.fetch(:start) - half_silence].max.to_i
|
|
203
|
+
else
|
|
204
|
+
speech[:end] = [audio_length_samples, speech.fetch(:end) + speech_pad_samples].min.to_i
|
|
205
|
+
following[:start] = [0, following.fetch(:start) - speech_pad_samples].max.to_i
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
private_class_method :pad_speeches!
|
|
211
|
+
|
|
212
|
+
def check_cancellation(cancel_check)
|
|
213
|
+
cancel_check&.call
|
|
214
|
+
end
|
|
215
|
+
private_class_method :check_cancellation
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "transcribe/version"
|
|
4
|
+
require_relative "transcribe/constants"
|
|
5
|
+
require_relative "transcribe/errors"
|
|
6
|
+
require_relative "transcribe/types"
|
|
7
|
+
require_relative "transcribe/input"
|
|
8
|
+
require_relative "transcribe/loader"
|
|
9
|
+
require_relative "transcribe/api"
|
|
10
|
+
|
|
11
|
+
module Cohere
|
|
12
|
+
module Transcribe
|
|
13
|
+
# Ruby counterpart to the Python package's explicit root export contract.
|
|
14
|
+
# Internal implementation constants remain reachable through autoloads but
|
|
15
|
+
# are intentionally absent from this stable list.
|
|
16
|
+
PUBLIC_API = %w[
|
|
17
|
+
BatchTranscriptionError Error ProgressCallbackError ProgressEvent
|
|
18
|
+
PublicationOptions SubtitleCue Transcriber TranscriberBusyError
|
|
19
|
+
TranscriberClosedError TranscriptionConfigurationError TranscriptionError
|
|
20
|
+
TranscriptionInputError TranscriptionOptions TranscriptionProvenance
|
|
21
|
+
TranscriptionResult TranscriptionRun TranscriptionRuntimeError
|
|
22
|
+
TranscriptionSegment TranscriptionStatistics TranscriptionWord VERSION
|
|
23
|
+
transcribe
|
|
24
|
+
].freeze
|
|
25
|
+
end
|
|
26
|
+
end
|