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,165 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "monitor"
|
|
4
|
+
require "weakref"
|
|
5
|
+
|
|
6
|
+
module Cohere
|
|
7
|
+
module Transcribe
|
|
8
|
+
module Runtime
|
|
9
|
+
# Owns one reusable native ASR session. Across all ModelResources
|
|
10
|
+
# instances, only one may retain ASR at a time; this bounds process memory
|
|
11
|
+
# when applications create multiple reusable Transcribers.
|
|
12
|
+
class ModelResources
|
|
13
|
+
OWNER_GUARD = Monitor.new
|
|
14
|
+
|
|
15
|
+
class << self
|
|
16
|
+
def evict_current_asr_owner
|
|
17
|
+
OWNER_GUARD.synchronize do
|
|
18
|
+
owner = current_owner_locked
|
|
19
|
+
owner&.send(:evict_asr_locked)
|
|
20
|
+
end
|
|
21
|
+
nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def current_asr_owner
|
|
25
|
+
OWNER_GUARD.synchronize { current_owner_locked }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def current_owner_locked
|
|
31
|
+
reference = @owner_reference
|
|
32
|
+
return nil unless reference
|
|
33
|
+
|
|
34
|
+
reference.__getobj__
|
|
35
|
+
rescue WeakRef::RefError
|
|
36
|
+
@owner_reference = nil
|
|
37
|
+
nil
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def claim_locked(owner)
|
|
41
|
+
@owner_reference = WeakRef.new(owner)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def release_locked(owner)
|
|
45
|
+
@owner_reference = nil if current_owner_locked.equal?(owner)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
attr_reader :asr_key, :batch_controller
|
|
50
|
+
|
|
51
|
+
def initialize
|
|
52
|
+
@asr_key = nil
|
|
53
|
+
@asr_session = nil
|
|
54
|
+
@batch_controller = nil
|
|
55
|
+
@closed = false
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns [session, loaded]. A key change evicts this instance's prior
|
|
59
|
+
# session, while acquisition also evicts a different process owner.
|
|
60
|
+
def acquire_asr(key)
|
|
61
|
+
raise ArgumentError, "an ASR loader block is required" unless block_given?
|
|
62
|
+
|
|
63
|
+
self.class::OWNER_GUARD.synchronize do
|
|
64
|
+
ensure_open!
|
|
65
|
+
evict_asr_locked if @asr_session && @asr_key != key
|
|
66
|
+
|
|
67
|
+
owner = self.class.send(:current_owner_locked)
|
|
68
|
+
owner.send(:evict_asr_locked) if owner && !owner.equal?(self)
|
|
69
|
+
self.class.send(:claim_locked, self)
|
|
70
|
+
|
|
71
|
+
loaded = false
|
|
72
|
+
unless @asr_session
|
|
73
|
+
installed = false
|
|
74
|
+
begin
|
|
75
|
+
session = yield
|
|
76
|
+
raise TranscriptionRuntimeError, "ASR loader returned no native session" if session.nil?
|
|
77
|
+
|
|
78
|
+
@asr_session = session
|
|
79
|
+
@asr_key = immutable_key(key)
|
|
80
|
+
@batch_controller = nil
|
|
81
|
+
loaded = true
|
|
82
|
+
installed = true
|
|
83
|
+
ensure
|
|
84
|
+
self.class.send(:release_locked, self) unless installed
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
[@asr_session, loaded].freeze
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def install_batch_controller(controller)
|
|
92
|
+
self.class::OWNER_GUARD.synchronize do
|
|
93
|
+
ensure_open!
|
|
94
|
+
raise TranscriptionRuntimeError, "Cannot install an ASR controller before acquiring ASR" unless @asr_session
|
|
95
|
+
|
|
96
|
+
@batch_controller ||= controller
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def asr_session
|
|
101
|
+
self.class::OWNER_GUARD.synchronize { @asr_session }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def asr?
|
|
105
|
+
self.class::OWNER_GUARD.synchronize { !@asr_session.nil? }
|
|
106
|
+
end
|
|
107
|
+
alias has_asr? asr?
|
|
108
|
+
|
|
109
|
+
def asr_circuit_broken?
|
|
110
|
+
self.class::OWNER_GUARD.synchronize do
|
|
111
|
+
@batch_controller&.circuit_open?
|
|
112
|
+
end || false
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def evict_asr
|
|
116
|
+
self.class::OWNER_GUARD.synchronize { evict_asr_locked }
|
|
117
|
+
nil
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def close
|
|
121
|
+
self.class::OWNER_GUARD.synchronize do
|
|
122
|
+
return if @closed
|
|
123
|
+
|
|
124
|
+
evict_asr_locked
|
|
125
|
+
@closed = true
|
|
126
|
+
end
|
|
127
|
+
nil
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def closed?
|
|
131
|
+
self.class::OWNER_GUARD.synchronize { @closed }
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
private
|
|
135
|
+
|
|
136
|
+
def ensure_open!
|
|
137
|
+
raise TranscriberClosedError, "Model resources have been closed" if @closed
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def evict_asr_locked
|
|
141
|
+
self.class.send(:release_locked, self)
|
|
142
|
+
session = @asr_session
|
|
143
|
+
@asr_session = nil
|
|
144
|
+
@asr_key = nil
|
|
145
|
+
@batch_controller = nil
|
|
146
|
+
session&.close
|
|
147
|
+
nil
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def immutable_key(value)
|
|
151
|
+
case value
|
|
152
|
+
when Array
|
|
153
|
+
value.map { |item| immutable_key(item) }.freeze
|
|
154
|
+
when Hash
|
|
155
|
+
value.to_h { |key, item| [immutable_key(key), immutable_key(item)] }.freeze
|
|
156
|
+
when String
|
|
157
|
+
value.dup.freeze
|
|
158
|
+
else
|
|
159
|
+
value
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cohere
|
|
4
|
+
module Transcribe
|
|
5
|
+
module Runtime
|
|
6
|
+
# Scheduling primitives for word-aligned runs. The coordinator creates a
|
|
7
|
+
# hard phase barrier: every ASR outcome is collected before Dense is
|
|
8
|
+
# evicted, and no alignment callback can run before that eviction.
|
|
9
|
+
module WordPipeline
|
|
10
|
+
UNSET = Object.new.freeze
|
|
11
|
+
private_constant :UNSET
|
|
12
|
+
|
|
13
|
+
# The complete state needed after ASR. Deliberately absent are decoded
|
|
14
|
+
# samples (or a decoder result): multi-file word mode must re-decode one
|
|
15
|
+
# source at a time instead of retaining every waveform until alignment.
|
|
16
|
+
AlignmentWork = Data.define(
|
|
17
|
+
:index,
|
|
18
|
+
:entry,
|
|
19
|
+
:plan,
|
|
20
|
+
:result,
|
|
21
|
+
:segment_times,
|
|
22
|
+
:speech_spans,
|
|
23
|
+
:generation_id,
|
|
24
|
+
:decode_backend,
|
|
25
|
+
:expected_sample_count,
|
|
26
|
+
:audio_required,
|
|
27
|
+
:source_snapshot
|
|
28
|
+
) do
|
|
29
|
+
def initialize(index:, entry:, plan:, result:, segment_times:, speech_spans:,
|
|
30
|
+
generation_id:, decode_backend:, expected_sample_count:, audio_required:,
|
|
31
|
+
source_snapshot:)
|
|
32
|
+
index = Integer(index)
|
|
33
|
+
expected_sample_count = Integer(expected_sample_count)
|
|
34
|
+
raise ArgumentError, "word-pipeline index must be nonnegative" if index.negative?
|
|
35
|
+
raise ArgumentError, "expected alignment sample count must be nonnegative" if expected_sample_count.negative?
|
|
36
|
+
|
|
37
|
+
super(
|
|
38
|
+
index: index,
|
|
39
|
+
entry: entry,
|
|
40
|
+
plan: plan,
|
|
41
|
+
result: result,
|
|
42
|
+
segment_times: immutable_spans(segment_times, "segment_times"),
|
|
43
|
+
speech_spans: immutable_spans(speech_spans, "speech_spans"),
|
|
44
|
+
generation_id: immutable_optional_string(generation_id),
|
|
45
|
+
decode_backend: immutable_optional_string(decode_backend),
|
|
46
|
+
expected_sample_count: expected_sample_count,
|
|
47
|
+
audio_required: !!audio_required,
|
|
48
|
+
source_snapshot: immutable_snapshot(source_snapshot)
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def immutable_spans(value, label)
|
|
55
|
+
raise ArgumentError, "#{label} must be an array" unless value.is_a?(Array)
|
|
56
|
+
|
|
57
|
+
value.map do |span|
|
|
58
|
+
raise ArgumentError, "#{label} contains an invalid span" unless
|
|
59
|
+
span.is_a?(Array) && span.length == 2 && span.all?(Numeric)
|
|
60
|
+
|
|
61
|
+
[span.fetch(0).to_f, span.fetch(1).to_f].freeze
|
|
62
|
+
end.freeze
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def immutable_optional_string(value)
|
|
66
|
+
return nil if value.nil?
|
|
67
|
+
raise ArgumentError, "word-pipeline metadata strings must be strings" unless value.is_a?(String)
|
|
68
|
+
|
|
69
|
+
value.dup.freeze
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def immutable_snapshot(value)
|
|
73
|
+
value.is_a?(Array) ? value.dup.freeze : value
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
Final = Data.define(:index, :result) do
|
|
78
|
+
def initialize(index:, result:)
|
|
79
|
+
index = Integer(index)
|
|
80
|
+
raise ArgumentError, "word-pipeline index must be nonnegative" if index.negative?
|
|
81
|
+
|
|
82
|
+
super
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
ReloadResult = Data.define(:decoded, :error) do
|
|
87
|
+
def ok?
|
|
88
|
+
error.nil?
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Executes an ordered two-phase batch. The ASR callback returns either
|
|
93
|
+
# AlignmentWork or Final. Alignment errors intended to be per-file must
|
|
94
|
+
# likewise be converted to a final result by the alignment callback;
|
|
95
|
+
# fatal/cancellation exceptions intentionally cross this boundary.
|
|
96
|
+
class Coordinator
|
|
97
|
+
def initialize(total:, evict_asr:, align:, fixed_results: {}, completed: nil, gc_interval: 8,
|
|
98
|
+
reload: nil, memory_byte_limit: nil, start_alignment: nil)
|
|
99
|
+
@total = Integer(total)
|
|
100
|
+
raise ArgumentError, "word-pipeline total must be nonnegative" if @total.negative?
|
|
101
|
+
raise ArgumentError, "evict_asr must respond to call" unless evict_asr.respond_to?(:call)
|
|
102
|
+
raise ArgumentError, "align must respond to call" unless align.respond_to?(:call)
|
|
103
|
+
raise ArgumentError, "completed must respond to call" if completed && !completed.respond_to?(:call)
|
|
104
|
+
raise ArgumentError, "start_alignment must respond to call" if
|
|
105
|
+
start_alignment && !start_alignment.respond_to?(:call)
|
|
106
|
+
|
|
107
|
+
@fixed_results = fixed_results.to_h.freeze
|
|
108
|
+
@evict_asr = evict_asr
|
|
109
|
+
@align = align
|
|
110
|
+
@completed = completed
|
|
111
|
+
@gc_interval = Integer(gc_interval)
|
|
112
|
+
raise ArgumentError, "gc_interval must be positive" unless @gc_interval.positive?
|
|
113
|
+
raise ArgumentError, "reload and memory_byte_limit must be provided together" unless
|
|
114
|
+
reload.nil? == memory_byte_limit.nil?
|
|
115
|
+
raise ArgumentError, "reload must respond to call" if reload && !reload.respond_to?(:call)
|
|
116
|
+
|
|
117
|
+
@reload = reload
|
|
118
|
+
@start_alignment = start_alignment
|
|
119
|
+
@memory_byte_limit = Integer(memory_byte_limit) if memory_byte_limit
|
|
120
|
+
raise ArgumentError, "memory_byte_limit must be positive" if
|
|
121
|
+
@memory_byte_limit && !@memory_byte_limit.positive?
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def run(prepared, &asr)
|
|
125
|
+
raise ArgumentError, "an ASR callback is required" unless asr
|
|
126
|
+
|
|
127
|
+
slots = Array.new(@total, UNSET)
|
|
128
|
+
@fixed_results.each do |index, result|
|
|
129
|
+
outcome = if result.is_a?(AlignmentWork) || result.is_a?(Final)
|
|
130
|
+
result
|
|
131
|
+
else
|
|
132
|
+
Final.new(index: index, result: result)
|
|
133
|
+
end
|
|
134
|
+
install!(slots, outcome)
|
|
135
|
+
end
|
|
136
|
+
transitioned = false
|
|
137
|
+
begin
|
|
138
|
+
collect_asr!(slots, prepared, &asr)
|
|
139
|
+
missing = slots.each_index.select { |index| slots.fetch(index).equal?(UNSET) }
|
|
140
|
+
unless missing.empty?
|
|
141
|
+
raise TranscriptionRuntimeError,
|
|
142
|
+
"Word ASR phase omitted input index(es): #{missing.join(", ")}"
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Set the flag before calling so an eviction exception is not
|
|
146
|
+
# followed by a second, potentially destructive close attempt.
|
|
147
|
+
transitioned = true
|
|
148
|
+
alignment_required = slots.grep(AlignmentWork).any?(&:audio_required)
|
|
149
|
+
@evict_asr.call if alignment_required
|
|
150
|
+
|
|
151
|
+
align_slots!(slots)
|
|
152
|
+
completed_count = 0
|
|
153
|
+
slots.each_with_index do |outcome, index|
|
|
154
|
+
result = outcome.is_a?(Final) ? outcome.result : outcome
|
|
155
|
+
raise TranscriptionRuntimeError, "Word pipeline returned no result for input #{index}" if result.nil?
|
|
156
|
+
|
|
157
|
+
slots[index] = result
|
|
158
|
+
completed_count += 1
|
|
159
|
+
@completed&.call(index, completed_count, @total, result)
|
|
160
|
+
GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true) if
|
|
161
|
+
(completed_count % @gc_interval).zero?
|
|
162
|
+
end
|
|
163
|
+
slots.freeze
|
|
164
|
+
ensure
|
|
165
|
+
@evict_asr.call unless transitioned
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
private
|
|
170
|
+
|
|
171
|
+
# Keeping ASR collection in its own frame guarantees that the final
|
|
172
|
+
# PreparedEntry (and its PCM) is unreachable before alignment starts.
|
|
173
|
+
def collect_asr!(slots, prepared)
|
|
174
|
+
prepared.each { |prepared_entry| install!(slots, yield(prepared_entry)) }
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def align_slots!(slots)
|
|
178
|
+
works = slots.grep(AlignmentWork)
|
|
179
|
+
if @reload
|
|
180
|
+
PairBudgetReload.new(
|
|
181
|
+
works,
|
|
182
|
+
memory_byte_limit: @memory_byte_limit,
|
|
183
|
+
reload: @reload,
|
|
184
|
+
started: -> { @start_alignment&.call(works) }
|
|
185
|
+
).each do |work, reload_result|
|
|
186
|
+
slots[work.index] = alignment_result(work, reload_result)
|
|
187
|
+
end
|
|
188
|
+
else
|
|
189
|
+
works.each { |work| slots[work.index] = alignment_result(work) }
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def alignment_result(work, reload_result = UNSET)
|
|
194
|
+
aligned = if reload_result.equal?(UNSET)
|
|
195
|
+
@align.call(work)
|
|
196
|
+
else
|
|
197
|
+
@align.call(work, reload_result)
|
|
198
|
+
end
|
|
199
|
+
if aligned.is_a?(AlignmentWork) || aligned.is_a?(Final)
|
|
200
|
+
raise TranscriptionRuntimeError,
|
|
201
|
+
"Word alignment returned a scheduler outcome instead of a result"
|
|
202
|
+
end
|
|
203
|
+
aligned
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def install!(slots, outcome)
|
|
207
|
+
unless outcome.is_a?(AlignmentWork) || outcome.is_a?(Final)
|
|
208
|
+
raise TranscriptionRuntimeError,
|
|
209
|
+
"Word ASR phase must return AlignmentWork or Final, got #{outcome.class}"
|
|
210
|
+
end
|
|
211
|
+
index = outcome.index
|
|
212
|
+
unless index.between?(0, @total - 1)
|
|
213
|
+
raise TranscriptionRuntimeError,
|
|
214
|
+
"Word ASR phase returned out-of-range input index #{index}"
|
|
215
|
+
end
|
|
216
|
+
raise TranscriptionRuntimeError, "Word ASR phase returned input #{index} more than once" unless
|
|
217
|
+
slots.fetch(index).equal?(UNSET)
|
|
218
|
+
|
|
219
|
+
slots[index] = outcome
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Reloads alignment PCM with one worker and at most one lookahead. The
|
|
224
|
+
# next file may overlap MMS computation only when the current/next PCM
|
|
225
|
+
# pair fits the configured budget; otherwise the current reference is
|
|
226
|
+
# dropped before the next decode starts.
|
|
227
|
+
class PairBudgetReload
|
|
228
|
+
SAMPLE_BYTES = 4
|
|
229
|
+
|
|
230
|
+
def initialize(works, memory_byte_limit:, reload:, started: nil)
|
|
231
|
+
@works = works.to_a.freeze
|
|
232
|
+
@memory_byte_limit = Integer(memory_byte_limit)
|
|
233
|
+
raise ArgumentError, "memory_byte_limit must be positive" unless @memory_byte_limit.positive?
|
|
234
|
+
raise ArgumentError, "reload must respond to call" unless reload.respond_to?(:call)
|
|
235
|
+
raise ArgumentError, "started must respond to call" if started && !started.respond_to?(:call)
|
|
236
|
+
|
|
237
|
+
@reload = reload
|
|
238
|
+
@started = started
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def each
|
|
242
|
+
return enum_for(__method__) unless block_given?
|
|
243
|
+
return if @works.empty?
|
|
244
|
+
|
|
245
|
+
pending = submit(@works.first, 0)
|
|
246
|
+
@started&.call
|
|
247
|
+
@works.each_with_index do |work, index|
|
|
248
|
+
current = pending
|
|
249
|
+
pending = nil
|
|
250
|
+
reload_result = current.value
|
|
251
|
+
current = nil # rubocop:disable Lint/UselessAssignment -- release Thread#value before a serial decode
|
|
252
|
+
|
|
253
|
+
next_work = @works[index + 1]
|
|
254
|
+
pending = submit(next_work, index + 1) if next_work && pair_fits?(work, next_work)
|
|
255
|
+
yield [work, reload_result].freeze
|
|
256
|
+
reload_result = nil # rubocop:disable Lint/UselessAssignment -- release PCM before a serial decode
|
|
257
|
+
unless pending || next_work.nil?
|
|
258
|
+
GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true)
|
|
259
|
+
pending = submit(next_work, index + 1)
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
completed = true
|
|
263
|
+
ensure
|
|
264
|
+
cancel(pending) if defined?(pending) && pending
|
|
265
|
+
cancel(current) if defined?(current) && current
|
|
266
|
+
GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true) if defined?(completed) && completed
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
private
|
|
270
|
+
|
|
271
|
+
def pair_fits?(left, right)
|
|
272
|
+
pcm_bytes(left) + pcm_bytes(right) <= @memory_byte_limit
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def pcm_bytes(work)
|
|
276
|
+
work.audio_required ? work.expected_sample_count * SAMPLE_BYTES : 0
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def submit(work, index)
|
|
280
|
+
Thread.new do
|
|
281
|
+
Thread.current.name = "cohere-alignment-reload-#{index}" if Thread.current.respond_to?(:name=)
|
|
282
|
+
begin
|
|
283
|
+
ReloadResult.new(decoded: @reload.call(work), error: nil)
|
|
284
|
+
rescue StandardError => e
|
|
285
|
+
ReloadResult.new(decoded: nil, error: e)
|
|
286
|
+
end
|
|
287
|
+
end.tap { |thread| thread.report_on_exception = false }
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def cancel(thread)
|
|
291
|
+
begin
|
|
292
|
+
@reload.cancel if @reload.respond_to?(:cancel)
|
|
293
|
+
rescue StandardError
|
|
294
|
+
nil
|
|
295
|
+
end
|
|
296
|
+
thread.kill if thread.alive?
|
|
297
|
+
thread.join
|
|
298
|
+
rescue Exception # rubocop:disable Lint/RescueException -- preserve caller cancellation/failure
|
|
299
|
+
nil
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Re-decodes one alignment candidate with the concrete backend recorded
|
|
304
|
+
# during ASR/checkpointing. It rejects automatic fallback and sample
|
|
305
|
+
# drift, which makes the second decode reproducible and source-consistent.
|
|
306
|
+
class ConcreteRedecoder
|
|
307
|
+
def initialize(decoder:, sample_rate:, memory_byte_limit:, validate: nil, skip: nil)
|
|
308
|
+
@decoder = decoder
|
|
309
|
+
@sample_rate = Integer(sample_rate)
|
|
310
|
+
@memory_byte_limit = Integer(memory_byte_limit)
|
|
311
|
+
raise ArgumentError, "sample_rate must be positive" unless @sample_rate.positive?
|
|
312
|
+
raise ArgumentError, "memory_byte_limit must be positive" unless @memory_byte_limit.positive?
|
|
313
|
+
raise ArgumentError, "validate must respond to call" if validate && !validate.respond_to?(:call)
|
|
314
|
+
raise ArgumentError, "skip must respond to call" if skip && !skip.respond_to?(:call)
|
|
315
|
+
|
|
316
|
+
@validate = validate
|
|
317
|
+
@skip = skip
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
def call(work)
|
|
321
|
+
return nil if @skip&.call(work)
|
|
322
|
+
|
|
323
|
+
@validate&.call(work)
|
|
324
|
+
return nil unless work.audio_required
|
|
325
|
+
|
|
326
|
+
backend = work.decode_backend
|
|
327
|
+
if backend.nil? || backend.empty? || backend == "auto"
|
|
328
|
+
raise TranscriptionRuntimeError,
|
|
329
|
+
"Cannot re-decode #{work.entry.path} for word alignment without a concrete ASR backend"
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
decoded = @decoder.decode(
|
|
333
|
+
work.entry.path,
|
|
334
|
+
backend: backend,
|
|
335
|
+
sample_rate: @sample_rate,
|
|
336
|
+
max_decoded_bytes: @memory_byte_limit
|
|
337
|
+
)
|
|
338
|
+
if decoded.backend != backend
|
|
339
|
+
raise TranscriptionRuntimeError,
|
|
340
|
+
"Alignment decoder backend changed for #{work.entry.path}: " \
|
|
341
|
+
"#{backend} -> #{decoded.backend}"
|
|
342
|
+
end
|
|
343
|
+
unless decoded.samples.length == work.expected_sample_count
|
|
344
|
+
raise TranscriptionRuntimeError,
|
|
345
|
+
"Decoded sample count changed between ASR and alignment for #{work.entry.path}: " \
|
|
346
|
+
"#{decoded.samples.length} != #{work.expected_sample_count}"
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
@validate&.call(work)
|
|
350
|
+
decoded
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
def cancel
|
|
354
|
+
Audio::FFmpegNative.cancel_active! if
|
|
355
|
+
defined?(Audio::FFmpegNative) && Audio::FFmpegNative.respond_to?(:cancel_active!)
|
|
356
|
+
nil
|
|
357
|
+
rescue StandardError
|
|
358
|
+
nil
|
|
359
|
+
end
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
end
|