nexaai 1.0.29__cp310-cp310-macosx_14_0_universal2.whl
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.
- nexaai/__init__.py +99 -0
- nexaai/_stub.cpython-310-darwin.so +0 -0
- nexaai/_version.py +4 -0
- nexaai/asr.py +68 -0
- nexaai/asr_impl/__init__.py +0 -0
- nexaai/asr_impl/mlx_asr_impl.py +93 -0
- nexaai/asr_impl/pybind_asr_impl.py +127 -0
- nexaai/base.py +39 -0
- nexaai/binds/__init__.py +7 -0
- nexaai/binds/asr_bind.cpython-310-darwin.so +0 -0
- nexaai/binds/common_bind.cpython-310-darwin.so +0 -0
- nexaai/binds/cpu_gpu/libggml-base.dylib +0 -0
- nexaai/binds/cpu_gpu/libggml-cpu.so +0 -0
- nexaai/binds/cpu_gpu/libggml-metal.so +0 -0
- nexaai/binds/cpu_gpu/libggml.dylib +0 -0
- nexaai/binds/cpu_gpu/libmtmd.dylib +0 -0
- nexaai/binds/cpu_gpu/libnexa_cpu_gpu.dylib +0 -0
- nexaai/binds/cpu_gpu/libnexa_plugin.dylib +0 -0
- nexaai/binds/cv_bind.cpython-310-darwin.so +0 -0
- nexaai/binds/diarize_bind.cpython-310-darwin.so +0 -0
- nexaai/binds/embedder_bind.cpython-310-darwin.so +0 -0
- nexaai/binds/libnexa_bridge.dylib +0 -0
- nexaai/binds/llm_bind.cpython-310-darwin.so +0 -0
- nexaai/binds/metal/libnexa_plugin.dylib +0 -0
- nexaai/binds/metal/py-lib/ml.py +888 -0
- nexaai/binds/metal/py-lib/mlx_audio/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/__init__.py +5 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/bigvgan/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/bigvgan/activation.py +51 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/bigvgan/amp.py +96 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/bigvgan/bigvgan.py +149 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/bigvgan/conv.py +114 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/bigvgan/resample.py +177 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/descript/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/descript/base.py +228 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/descript/dac.py +285 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/descript/nn/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/descript/nn/layers.py +129 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/descript/nn/quantize.py +149 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/encodec/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/encodec/encodec.py +777 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/mimi/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/mimi/mimi.py +286 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/mimi/modules/__init__.py +20 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/mimi/modules/conv.py +398 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/mimi/modules/kv_cache.py +199 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/mimi/modules/quantization.py +179 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/mimi/modules/seanet.py +314 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/mimi/modules/transformer.py +256 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/s3/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/s3/model.py +260 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/s3/model_v2.py +383 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/s3/utils.py +122 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/snac/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/snac/attention.py +97 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/snac/layers.py +306 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/snac/snac.py +154 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/snac/vq.py +135 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/vocos/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/vocos/mel.py +33 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/models/vocos/vocos.py +359 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/tests/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/tests/test_bigvgan.py +54 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/tests/test_descript.py +109 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/tests/test_encodec.py +58 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/tests/test_mimi.py +22 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/tests/test_s3.py +25 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/tests/test_snac.py +40 -0
- nexaai/binds/metal/py-lib/mlx_audio/codec/tests/test_vocos.py +93 -0
- nexaai/binds/metal/py-lib/mlx_audio/server.py +525 -0
- nexaai/binds/metal/py-lib/mlx_audio/sts/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/sts/tests/test_voice_pipeline.py +156 -0
- nexaai/binds/metal/py-lib/mlx_audio/sts/voice_pipeline.py +327 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/generate.py +174 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/parakeet/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/parakeet/alignment.py +248 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/parakeet/attention.py +187 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/parakeet/audio.py +76 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/parakeet/conformer.py +331 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/parakeet/ctc.py +34 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/parakeet/parakeet.py +604 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/parakeet/rnnt.py +157 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/parakeet/tokenizer.py +2 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/wav2vec/feature_extractor.py +757 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/wav2vec/wav2vec.py +738 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/whisper/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/whisper/audio.py +82 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/whisper/decoding.py +742 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/whisper/timing.py +329 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/whisper/tokenizer.py +398 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/whisper/whisper.py +862 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/models/whisper/writers.py +268 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/tests/test_models.py +381 -0
- nexaai/binds/metal/py-lib/mlx_audio/stt/utils.py +195 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/audio_player.py +120 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/convert.py +71 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/generate.py +449 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/bark/__init__.py +4 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/bark/bark.py +528 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/bark/isftnet.py +12 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/bark/pipeline.py +442 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/base.py +84 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/dia/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/dia/audio.py +287 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/dia/config.py +256 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/dia/dia.py +592 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/dia/layers.py +870 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/__init__.py +3 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/attention.py +180 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/bigvgan.py +124 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/conformer.py +247 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/ecapa_tdnn/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/ecapa_tdnn/asp.py +59 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/ecapa_tdnn/ecapa_tdnn.py +91 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/ecapa_tdnn/se_res2net.py +132 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/ecapa_tdnn/tdnn.py +42 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/gpt2.py +38 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/indextts.py +412 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/mel.py +37 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/normalize.py +294 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/indextts/perceiver.py +62 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/interpolate.py +108 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/kokoro/__init__.py +4 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/kokoro/istftnet.py +979 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/kokoro/kokoro.py +331 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/kokoro/modules.py +659 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/kokoro/pipeline.py +453 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/kokoro/voice.py +113 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/llama/__init__.py +3 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/llama/llama.py +324 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/outetts/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/outetts/audio_processor.py +351 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/outetts/dac_interface.py +162 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/outetts/outetts.py +255 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/outetts/prompt_processor.py +181 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/outetts/tokens.py +36 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/sesame/__init__.py +3 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/sesame/attention.py +195 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/sesame/sesame.py +633 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/sesame/watermarking.py +105 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/audio_tokenizer.py +138 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/bicodec.py +269 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/blocks/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/blocks/sampler.py +111 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/encoder_decoder/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/encoder_decoder/feat_decoder.py +120 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/encoder_decoder/feat_encoder.py +136 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/encoder_decoder/wave_generator.py +113 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/finite_scalar_quantization.py +238 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/residual.py +209 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/residual_fsq.py +309 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/speaker/__init__.py +1 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/speaker/ecapa_tdnn.py +283 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/speaker/perceiver_encoder.py +326 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/speaker/pooling_layers.py +297 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/modules/speaker/speaker_encoder.py +155 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/spark.py +382 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/utils/audio.py +220 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/utils/file.py +221 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/models/spark/utils/token_parser.py +181 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/tests/__init__.py +0 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/tests/test_base.py +66 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/tests/test_convert.py +173 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/tests/test_interpolate.py +88 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/tests/test_models.py +974 -0
- nexaai/binds/metal/py-lib/mlx_audio/tts/utils.py +337 -0
- nexaai/binds/metal/py-lib/mlx_audio/utils.py +237 -0
- nexaai/binds/metal/py-lib/mlx_audio/version.py +1 -0
- nexaai/binds/metal/py-lib/profiling.py +239 -0
- nexaai/binds/nexaml/libfftw3.3.dylib +0 -0
- nexaai/binds/nexaml/libfftw3f.3.dylib +0 -0
- nexaai/binds/nexaml/libggml-base.dylib +0 -0
- nexaai/binds/nexaml/libggml-cpu.so +0 -0
- nexaai/binds/nexaml/libggml-metal.so +0 -0
- nexaai/binds/nexaml/libggml.dylib +0 -0
- nexaai/binds/nexaml/libmp3lame.0.dylib +0 -0
- nexaai/binds/nexaml/libmpg123.0.dylib +0 -0
- nexaai/binds/nexaml/libnexa-mm-process.dylib +0 -0
- nexaai/binds/nexaml/libnexa-sampling.dylib +0 -0
- nexaai/binds/nexaml/libnexa_plugin.dylib +0 -0
- nexaai/binds/nexaml/libnexaproc.dylib +0 -0
- nexaai/binds/nexaml/libomp.dylib +0 -0
- nexaai/binds/nexaml/libqwen3-vl.dylib +0 -0
- nexaai/binds/nexaml/libqwen3vl-vision.dylib +0 -0
- nexaai/binds/rerank_bind.cpython-310-darwin.so +0 -0
- nexaai/binds/vlm_bind.cpython-310-darwin.so +0 -0
- nexaai/common.py +106 -0
- nexaai/cv.py +95 -0
- nexaai/cv_impl/__init__.py +0 -0
- nexaai/cv_impl/mlx_cv_impl.py +91 -0
- nexaai/cv_impl/pybind_cv_impl.py +124 -0
- nexaai/diarize.py +80 -0
- nexaai/diarize_impl/__init__.py +1 -0
- nexaai/diarize_impl/pybind_diarize_impl.py +125 -0
- nexaai/embedder.py +73 -0
- nexaai/embedder_impl/__init__.py +0 -0
- nexaai/embedder_impl/mlx_embedder_impl.py +118 -0
- nexaai/embedder_impl/pybind_embedder_impl.py +96 -0
- nexaai/image_gen.py +141 -0
- nexaai/image_gen_impl/__init__.py +0 -0
- nexaai/image_gen_impl/mlx_image_gen_impl.py +292 -0
- nexaai/image_gen_impl/pybind_image_gen_impl.py +85 -0
- nexaai/llm.py +98 -0
- nexaai/llm_impl/__init__.py +0 -0
- nexaai/llm_impl/mlx_llm_impl.py +271 -0
- nexaai/llm_impl/pybind_llm_impl.py +238 -0
- nexaai/log.py +92 -0
- nexaai/mlx_backend/asr/__init__.py +12 -0
- nexaai/mlx_backend/asr/interface.py +122 -0
- nexaai/mlx_backend/common/__init__.py +0 -0
- nexaai/mlx_backend/common/utils.py +25 -0
- nexaai/mlx_backend/cv/__init__.py +0 -0
- nexaai/mlx_backend/cv/generate.py +195 -0
- nexaai/mlx_backend/cv/interface.py +162 -0
- nexaai/mlx_backend/cv/main.py +81 -0
- nexaai/mlx_backend/cv/modeling/pp_ocr_v4.py +1736 -0
- nexaai/mlx_backend/embedding/__init__.py +0 -0
- nexaai/mlx_backend/embedding/generate.py +333 -0
- nexaai/mlx_backend/embedding/interface.py +617 -0
- nexaai/mlx_backend/embedding/main.py +173 -0
- nexaai/mlx_backend/embedding/modeling/__init__.py +0 -0
- nexaai/mlx_backend/embedding/modeling/nexa_jina_v2.py +399 -0
- nexaai/mlx_backend/image_gen/__init__.py +1 -0
- nexaai/mlx_backend/image_gen/generate_sd.py +244 -0
- nexaai/mlx_backend/image_gen/interface.py +82 -0
- nexaai/mlx_backend/image_gen/main.py +281 -0
- nexaai/mlx_backend/image_gen/stable_diffusion/__init__.py +306 -0
- nexaai/mlx_backend/image_gen/stable_diffusion/clip.py +116 -0
- nexaai/mlx_backend/image_gen/stable_diffusion/config.py +65 -0
- nexaai/mlx_backend/image_gen/stable_diffusion/model_io.py +386 -0
- nexaai/mlx_backend/image_gen/stable_diffusion/sampler.py +105 -0
- nexaai/mlx_backend/image_gen/stable_diffusion/tokenizer.py +100 -0
- nexaai/mlx_backend/image_gen/stable_diffusion/unet.py +460 -0
- nexaai/mlx_backend/image_gen/stable_diffusion/vae.py +274 -0
- nexaai/mlx_backend/llm/__init__.py +0 -0
- nexaai/mlx_backend/llm/generate.py +149 -0
- nexaai/mlx_backend/llm/interface.py +764 -0
- nexaai/mlx_backend/llm/main.py +68 -0
- nexaai/mlx_backend/ml.py +888 -0
- nexaai/mlx_backend/mlx_audio/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/codec/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/codec/models/__init__.py +5 -0
- nexaai/mlx_backend/mlx_audio/codec/models/bigvgan/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/codec/models/bigvgan/activation.py +51 -0
- nexaai/mlx_backend/mlx_audio/codec/models/bigvgan/amp.py +96 -0
- nexaai/mlx_backend/mlx_audio/codec/models/bigvgan/bigvgan.py +149 -0
- nexaai/mlx_backend/mlx_audio/codec/models/bigvgan/conv.py +114 -0
- nexaai/mlx_backend/mlx_audio/codec/models/bigvgan/resample.py +177 -0
- nexaai/mlx_backend/mlx_audio/codec/models/descript/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/codec/models/descript/base.py +228 -0
- nexaai/mlx_backend/mlx_audio/codec/models/descript/dac.py +285 -0
- nexaai/mlx_backend/mlx_audio/codec/models/descript/nn/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/codec/models/descript/nn/layers.py +129 -0
- nexaai/mlx_backend/mlx_audio/codec/models/descript/nn/quantize.py +149 -0
- nexaai/mlx_backend/mlx_audio/codec/models/encodec/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/codec/models/encodec/encodec.py +777 -0
- nexaai/mlx_backend/mlx_audio/codec/models/mimi/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/codec/models/mimi/mimi.py +286 -0
- nexaai/mlx_backend/mlx_audio/codec/models/mimi/modules/__init__.py +20 -0
- nexaai/mlx_backend/mlx_audio/codec/models/mimi/modules/conv.py +398 -0
- nexaai/mlx_backend/mlx_audio/codec/models/mimi/modules/kv_cache.py +199 -0
- nexaai/mlx_backend/mlx_audio/codec/models/mimi/modules/quantization.py +179 -0
- nexaai/mlx_backend/mlx_audio/codec/models/mimi/modules/seanet.py +314 -0
- nexaai/mlx_backend/mlx_audio/codec/models/mimi/modules/transformer.py +256 -0
- nexaai/mlx_backend/mlx_audio/codec/models/s3/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/codec/models/s3/model.py +260 -0
- nexaai/mlx_backend/mlx_audio/codec/models/s3/model_v2.py +383 -0
- nexaai/mlx_backend/mlx_audio/codec/models/s3/utils.py +122 -0
- nexaai/mlx_backend/mlx_audio/codec/models/snac/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/codec/models/snac/attention.py +97 -0
- nexaai/mlx_backend/mlx_audio/codec/models/snac/layers.py +306 -0
- nexaai/mlx_backend/mlx_audio/codec/models/snac/snac.py +154 -0
- nexaai/mlx_backend/mlx_audio/codec/models/snac/vq.py +135 -0
- nexaai/mlx_backend/mlx_audio/codec/models/vocos/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/codec/models/vocos/mel.py +33 -0
- nexaai/mlx_backend/mlx_audio/codec/models/vocos/vocos.py +359 -0
- nexaai/mlx_backend/mlx_audio/codec/tests/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/codec/tests/test_bigvgan.py +54 -0
- nexaai/mlx_backend/mlx_audio/codec/tests/test_descript.py +109 -0
- nexaai/mlx_backend/mlx_audio/codec/tests/test_encodec.py +58 -0
- nexaai/mlx_backend/mlx_audio/codec/tests/test_mimi.py +22 -0
- nexaai/mlx_backend/mlx_audio/codec/tests/test_s3.py +25 -0
- nexaai/mlx_backend/mlx_audio/codec/tests/test_snac.py +40 -0
- nexaai/mlx_backend/mlx_audio/codec/tests/test_vocos.py +93 -0
- nexaai/mlx_backend/mlx_audio/server.py +525 -0
- nexaai/mlx_backend/mlx_audio/sts/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/sts/tests/test_voice_pipeline.py +156 -0
- nexaai/mlx_backend/mlx_audio/sts/voice_pipeline.py +327 -0
- nexaai/mlx_backend/mlx_audio/stt/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/stt/generate.py +174 -0
- nexaai/mlx_backend/mlx_audio/stt/models/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/stt/models/parakeet/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/stt/models/parakeet/alignment.py +248 -0
- nexaai/mlx_backend/mlx_audio/stt/models/parakeet/attention.py +187 -0
- nexaai/mlx_backend/mlx_audio/stt/models/parakeet/audio.py +76 -0
- nexaai/mlx_backend/mlx_audio/stt/models/parakeet/conformer.py +331 -0
- nexaai/mlx_backend/mlx_audio/stt/models/parakeet/ctc.py +34 -0
- nexaai/mlx_backend/mlx_audio/stt/models/parakeet/parakeet.py +604 -0
- nexaai/mlx_backend/mlx_audio/stt/models/parakeet/rnnt.py +157 -0
- nexaai/mlx_backend/mlx_audio/stt/models/parakeet/tokenizer.py +2 -0
- nexaai/mlx_backend/mlx_audio/stt/models/wav2vec/feature_extractor.py +757 -0
- nexaai/mlx_backend/mlx_audio/stt/models/wav2vec/wav2vec.py +738 -0
- nexaai/mlx_backend/mlx_audio/stt/models/whisper/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/stt/models/whisper/audio.py +82 -0
- nexaai/mlx_backend/mlx_audio/stt/models/whisper/decoding.py +742 -0
- nexaai/mlx_backend/mlx_audio/stt/models/whisper/timing.py +329 -0
- nexaai/mlx_backend/mlx_audio/stt/models/whisper/tokenizer.py +398 -0
- nexaai/mlx_backend/mlx_audio/stt/models/whisper/whisper.py +862 -0
- nexaai/mlx_backend/mlx_audio/stt/models/whisper/writers.py +268 -0
- nexaai/mlx_backend/mlx_audio/stt/tests/test_models.py +381 -0
- nexaai/mlx_backend/mlx_audio/stt/utils.py +195 -0
- nexaai/mlx_backend/mlx_audio/tts/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/tts/audio_player.py +120 -0
- nexaai/mlx_backend/mlx_audio/tts/convert.py +71 -0
- nexaai/mlx_backend/mlx_audio/tts/generate.py +449 -0
- nexaai/mlx_backend/mlx_audio/tts/models/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/tts/models/bark/__init__.py +4 -0
- nexaai/mlx_backend/mlx_audio/tts/models/bark/bark.py +528 -0
- nexaai/mlx_backend/mlx_audio/tts/models/bark/isftnet.py +12 -0
- nexaai/mlx_backend/mlx_audio/tts/models/bark/pipeline.py +442 -0
- nexaai/mlx_backend/mlx_audio/tts/models/base.py +84 -0
- nexaai/mlx_backend/mlx_audio/tts/models/dia/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/tts/models/dia/audio.py +287 -0
- nexaai/mlx_backend/mlx_audio/tts/models/dia/config.py +256 -0
- nexaai/mlx_backend/mlx_audio/tts/models/dia/dia.py +592 -0
- nexaai/mlx_backend/mlx_audio/tts/models/dia/layers.py +870 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/__init__.py +3 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/attention.py +180 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/bigvgan.py +124 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/conformer.py +247 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/ecapa_tdnn/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/ecapa_tdnn/asp.py +59 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/ecapa_tdnn/ecapa_tdnn.py +91 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/ecapa_tdnn/se_res2net.py +132 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/ecapa_tdnn/tdnn.py +42 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/gpt2.py +38 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/indextts.py +412 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/mel.py +37 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/normalize.py +294 -0
- nexaai/mlx_backend/mlx_audio/tts/models/indextts/perceiver.py +62 -0
- nexaai/mlx_backend/mlx_audio/tts/models/interpolate.py +108 -0
- nexaai/mlx_backend/mlx_audio/tts/models/kokoro/__init__.py +4 -0
- nexaai/mlx_backend/mlx_audio/tts/models/kokoro/istftnet.py +979 -0
- nexaai/mlx_backend/mlx_audio/tts/models/kokoro/kokoro.py +331 -0
- nexaai/mlx_backend/mlx_audio/tts/models/kokoro/modules.py +659 -0
- nexaai/mlx_backend/mlx_audio/tts/models/kokoro/pipeline.py +453 -0
- nexaai/mlx_backend/mlx_audio/tts/models/kokoro/voice.py +113 -0
- nexaai/mlx_backend/mlx_audio/tts/models/llama/__init__.py +3 -0
- nexaai/mlx_backend/mlx_audio/tts/models/llama/llama.py +324 -0
- nexaai/mlx_backend/mlx_audio/tts/models/outetts/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/tts/models/outetts/audio_processor.py +351 -0
- nexaai/mlx_backend/mlx_audio/tts/models/outetts/dac_interface.py +162 -0
- nexaai/mlx_backend/mlx_audio/tts/models/outetts/default_speaker.json +461 -0
- nexaai/mlx_backend/mlx_audio/tts/models/outetts/outetts.py +255 -0
- nexaai/mlx_backend/mlx_audio/tts/models/outetts/prompt_processor.py +181 -0
- nexaai/mlx_backend/mlx_audio/tts/models/outetts/tokens.py +36 -0
- nexaai/mlx_backend/mlx_audio/tts/models/sesame/__init__.py +3 -0
- nexaai/mlx_backend/mlx_audio/tts/models/sesame/attention.py +195 -0
- nexaai/mlx_backend/mlx_audio/tts/models/sesame/sesame.py +633 -0
- nexaai/mlx_backend/mlx_audio/tts/models/sesame/watermarking.py +105 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/audio_tokenizer.py +138 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/bicodec.py +269 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/blocks/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/blocks/sampler.py +111 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/encoder_decoder/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/encoder_decoder/feat_decoder.py +120 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/encoder_decoder/feat_encoder.py +136 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/encoder_decoder/wave_generator.py +113 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/finite_scalar_quantization.py +238 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/residual.py +209 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/residual_fsq.py +309 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/speaker/__init__.py +1 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/speaker/ecapa_tdnn.py +283 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/speaker/perceiver_encoder.py +326 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/speaker/pooling_layers.py +297 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/modules/speaker/speaker_encoder.py +155 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/spark.py +382 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/utils/audio.py +220 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/utils/file.py +221 -0
- nexaai/mlx_backend/mlx_audio/tts/models/spark/utils/token_parser.py +181 -0
- nexaai/mlx_backend/mlx_audio/tts/tests/__init__.py +0 -0
- nexaai/mlx_backend/mlx_audio/tts/tests/test_base.py +66 -0
- nexaai/mlx_backend/mlx_audio/tts/tests/test_convert.py +173 -0
- nexaai/mlx_backend/mlx_audio/tts/tests/test_interpolate.py +88 -0
- nexaai/mlx_backend/mlx_audio/tts/tests/test_models.py +974 -0
- nexaai/mlx_backend/mlx_audio/tts/utils.py +337 -0
- nexaai/mlx_backend/mlx_audio/utils.py +237 -0
- nexaai/mlx_backend/mlx_audio/version.py +1 -0
- nexaai/mlx_backend/profiling.py +239 -0
- nexaai/mlx_backend/rerank/__init__.py +0 -0
- nexaai/mlx_backend/rerank/generate.py +174 -0
- nexaai/mlx_backend/rerank/interface.py +287 -0
- nexaai/mlx_backend/rerank/main.py +127 -0
- nexaai/mlx_backend/rerank/modeling/__init__.py +0 -0
- nexaai/mlx_backend/rerank/modeling/nexa_jina_rerank.py +330 -0
- nexaai/mlx_backend/sd/__init__.py +1 -0
- nexaai/mlx_backend/sd/interface.py +362 -0
- nexaai/mlx_backend/sd/main.py +286 -0
- nexaai/mlx_backend/sd/modeling/__init__.py +306 -0
- nexaai/mlx_backend/sd/modeling/clip.py +116 -0
- nexaai/mlx_backend/sd/modeling/config.py +65 -0
- nexaai/mlx_backend/sd/modeling/model_io.py +385 -0
- nexaai/mlx_backend/sd/modeling/sampler.py +105 -0
- nexaai/mlx_backend/sd/modeling/tokenizer.py +100 -0
- nexaai/mlx_backend/sd/modeling/unet.py +460 -0
- nexaai/mlx_backend/sd/modeling/vae.py +274 -0
- nexaai/mlx_backend/tts/__init__.py +12 -0
- nexaai/mlx_backend/tts/interface.py +276 -0
- nexaai/mlx_backend/vlm/__init__.py +3 -0
- nexaai/mlx_backend/vlm/generate.py +572 -0
- nexaai/mlx_backend/vlm/generate_qwen3_vl.py +374 -0
- nexaai/mlx_backend/vlm/generate_qwen3_vl_moe.py +259 -0
- nexaai/mlx_backend/vlm/interface.py +559 -0
- nexaai/mlx_backend/vlm/main.py +365 -0
- nexaai/mlx_backend/vlm/modeling/__init__.py +0 -0
- nexaai/mlx_backend/vlm/modeling/convert.py +68 -0
- nexaai/mlx_backend/vlm/modeling/models/__init__.py +0 -0
- nexaai/mlx_backend/vlm/modeling/models/aya_vision/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/aya_vision/aya_vision.py +193 -0
- nexaai/mlx_backend/vlm/modeling/models/aya_vision/interpolate.py +186 -0
- nexaai/mlx_backend/vlm/modeling/models/aya_vision/language.py +233 -0
- nexaai/mlx_backend/vlm/modeling/models/aya_vision/vision.py +503 -0
- nexaai/mlx_backend/vlm/modeling/models/base.py +202 -0
- nexaai/mlx_backend/vlm/modeling/models/cache.py +230 -0
- nexaai/mlx_backend/vlm/modeling/models/deepseek_vl_v2/__init__.py +10 -0
- nexaai/mlx_backend/vlm/modeling/models/deepseek_vl_v2/conversation.py +264 -0
- nexaai/mlx_backend/vlm/modeling/models/deepseek_vl_v2/deepseek_vl_v2.py +472 -0
- nexaai/mlx_backend/vlm/modeling/models/deepseek_vl_v2/language.py +591 -0
- nexaai/mlx_backend/vlm/modeling/models/deepseek_vl_v2/processing_deepsek_vl_v2.py +526 -0
- nexaai/mlx_backend/vlm/modeling/models/deepseek_vl_v2/vision.py +356 -0
- nexaai/mlx_backend/vlm/modeling/models/florence2/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/florence2/florence2.py +366 -0
- nexaai/mlx_backend/vlm/modeling/models/florence2/language.py +488 -0
- nexaai/mlx_backend/vlm/modeling/models/florence2/vision.py +591 -0
- nexaai/mlx_backend/vlm/modeling/models/gemma3/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/gemma3/gemma3.py +213 -0
- nexaai/mlx_backend/vlm/modeling/models/gemma3/language.py +315 -0
- nexaai/mlx_backend/vlm/modeling/models/gemma3/vision.py +238 -0
- nexaai/mlx_backend/vlm/modeling/models/gemma3n/__init__.py +2 -0
- nexaai/mlx_backend/vlm/modeling/models/gemma3n/audio.py +1038 -0
- nexaai/mlx_backend/vlm/modeling/models/gemma3n/config.py +139 -0
- nexaai/mlx_backend/vlm/modeling/models/gemma3n/gemma3n.py +322 -0
- nexaai/mlx_backend/vlm/modeling/models/gemma3n/language.py +629 -0
- nexaai/mlx_backend/vlm/modeling/models/gemma3n/vision.py +1022 -0
- nexaai/mlx_backend/vlm/modeling/models/idefics2/__init__.py +9 -0
- nexaai/mlx_backend/vlm/modeling/models/idefics2/idefics2.py +294 -0
- nexaai/mlx_backend/vlm/modeling/models/idefics2/language.py +191 -0
- nexaai/mlx_backend/vlm/modeling/models/idefics2/vision.py +267 -0
- nexaai/mlx_backend/vlm/modeling/models/idefics3/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/idefics3/idefics3.py +175 -0
- nexaai/mlx_backend/vlm/modeling/models/idefics3/language.py +192 -0
- nexaai/mlx_backend/vlm/modeling/models/idefics3/vision.py +233 -0
- nexaai/mlx_backend/vlm/modeling/models/internvl_chat/__init__.py +9 -0
- nexaai/mlx_backend/vlm/modeling/models/internvl_chat/internvl_chat.py +140 -0
- nexaai/mlx_backend/vlm/modeling/models/internvl_chat/language.py +220 -0
- nexaai/mlx_backend/vlm/modeling/models/internvl_chat/processor.py +393 -0
- nexaai/mlx_backend/vlm/modeling/models/internvl_chat/vision.py +293 -0
- nexaai/mlx_backend/vlm/modeling/models/kernels.py +307 -0
- nexaai/mlx_backend/vlm/modeling/models/kimi_vl/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/kimi_vl/kimi_vl.py +143 -0
- nexaai/mlx_backend/vlm/modeling/models/kimi_vl/language.py +509 -0
- nexaai/mlx_backend/vlm/modeling/models/kimi_vl/vision.py +522 -0
- nexaai/mlx_backend/vlm/modeling/models/llama4/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/llama4/language.py +386 -0
- nexaai/mlx_backend/vlm/modeling/models/llama4/llama4.py +138 -0
- nexaai/mlx_backend/vlm/modeling/models/llama4/vision.py +560 -0
- nexaai/mlx_backend/vlm/modeling/models/llava/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/llava/language.py +240 -0
- nexaai/mlx_backend/vlm/modeling/models/llava/llava.py +153 -0
- nexaai/mlx_backend/vlm/modeling/models/llava/vision.py +259 -0
- nexaai/mlx_backend/vlm/modeling/models/llava_bunny/__init__.py +9 -0
- nexaai/mlx_backend/vlm/modeling/models/llava_bunny/language.py +236 -0
- nexaai/mlx_backend/vlm/modeling/models/llava_bunny/llava_bunny.py +256 -0
- nexaai/mlx_backend/vlm/modeling/models/llava_bunny/vision.py +303 -0
- nexaai/mlx_backend/vlm/modeling/models/llava_next/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/llava_next/language.py +230 -0
- nexaai/mlx_backend/vlm/modeling/models/llava_next/llava_next.py +160 -0
- nexaai/mlx_backend/vlm/modeling/models/llava_next/vision.py +243 -0
- nexaai/mlx_backend/vlm/modeling/models/mistral3/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/mistral3/mistral3.py +283 -0
- nexaai/mlx_backend/vlm/modeling/models/mllama/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/mllama/language.py +416 -0
- nexaai/mlx_backend/vlm/modeling/models/mllama/mllama.py +172 -0
- nexaai/mlx_backend/vlm/modeling/models/mllama/vision.py +499 -0
- nexaai/mlx_backend/vlm/modeling/models/molmo/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/molmo/language.py +243 -0
- nexaai/mlx_backend/vlm/modeling/models/molmo/molmo.py +133 -0
- nexaai/mlx_backend/vlm/modeling/models/molmo/vision.py +465 -0
- nexaai/mlx_backend/vlm/modeling/models/multi_modality/__init__.py +10 -0
- nexaai/mlx_backend/vlm/modeling/models/multi_modality/language.py +230 -0
- nexaai/mlx_backend/vlm/modeling/models/multi_modality/multi_modality.py +385 -0
- nexaai/mlx_backend/vlm/modeling/models/multi_modality/sam.py +557 -0
- nexaai/mlx_backend/vlm/modeling/models/multi_modality/vision.py +526 -0
- nexaai/mlx_backend/vlm/modeling/models/paligemma/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/paligemma/language.py +282 -0
- nexaai/mlx_backend/vlm/modeling/models/paligemma/paligemma.py +160 -0
- nexaai/mlx_backend/vlm/modeling/models/paligemma/vision.py +242 -0
- nexaai/mlx_backend/vlm/modeling/models/phi3_v/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/phi3_v/language.py +21 -0
- nexaai/mlx_backend/vlm/modeling/models/phi3_v/phi3_v.py +243 -0
- nexaai/mlx_backend/vlm/modeling/models/phi3_v/su_rope.py +71 -0
- nexaai/mlx_backend/vlm/modeling/models/phi3_v/vision.py +324 -0
- nexaai/mlx_backend/vlm/modeling/models/pixtral/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/pixtral/language.py +229 -0
- nexaai/mlx_backend/vlm/modeling/models/pixtral/pixtral.py +161 -0
- nexaai/mlx_backend/vlm/modeling/models/pixtral/vision.py +320 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen2_5_vl/__init__.py +2 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen2_5_vl/config.py +108 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen2_5_vl/language.py +490 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen2_5_vl/qwen2_5_vl.py +168 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen2_5_vl/vision.py +414 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen2_vl/__init__.py +2 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen2_vl/config.py +104 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen2_vl/language.py +490 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen2_vl/qwen2_vl.py +167 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen2_vl/vision.py +312 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3_vl/llm_common/__init__.py +0 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3_vl/llm_common/base.py +117 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3_vl/llm_common/cache.py +531 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3_vl/llm_common/generate.py +701 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3_vl/llm_common/rope_utils.py +255 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3_vl/llm_common/sample_utils.py +303 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3_vl/llm_common/tokenizer_utils.py +407 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3_vl/processor.py +476 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3_vl/qwen3vl.py +1262 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3vl_moe/llm_common/__init__.py +0 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3vl_moe/llm_common/base.py +117 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3vl_moe/llm_common/cache.py +531 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3vl_moe/llm_common/generate.py +701 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3vl_moe/llm_common/rope_utils.py +255 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3vl_moe/llm_common/sample_utils.py +303 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3vl_moe/llm_common/tokenizer_utils.py +407 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3vl_moe/processor.py +476 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3vl_moe/qwen3vl_moe.py +1308 -0
- nexaai/mlx_backend/vlm/modeling/models/qwen3vl_moe/switch_layers.py +210 -0
- nexaai/mlx_backend/vlm/modeling/models/smolvlm/__init__.py +8 -0
- nexaai/mlx_backend/vlm/modeling/models/smolvlm/smolvlm.py +62 -0
- nexaai/mlx_backend/vlm/modeling/processing_qwen2_5_vl.py +209 -0
- nexaai/mlx_backend/vlm/modeling/processing_qwen2_vl.py +215 -0
- nexaai/mlx_backend/vlm/modeling/prompt_utils.py +474 -0
- nexaai/mlx_backend/vlm/modeling/sample_utils.py +39 -0
- nexaai/mlx_backend/vlm/modeling/tokenizer_utils.py +344 -0
- nexaai/mlx_backend/vlm/modeling/trainer/__init__.py +9 -0
- nexaai/mlx_backend/vlm/modeling/trainer/lora.py +70 -0
- nexaai/mlx_backend/vlm/modeling/trainer/trainer.py +296 -0
- nexaai/mlx_backend/vlm/modeling/trainer/utils.py +160 -0
- nexaai/mlx_backend/vlm/modeling/utils.py +928 -0
- nexaai/rerank.py +57 -0
- nexaai/rerank_impl/__init__.py +0 -0
- nexaai/rerank_impl/mlx_rerank_impl.py +94 -0
- nexaai/rerank_impl/pybind_rerank_impl.py +136 -0
- nexaai/runtime.py +68 -0
- nexaai/runtime_error.py +24 -0
- nexaai/tts.py +75 -0
- nexaai/tts_impl/__init__.py +0 -0
- nexaai/tts_impl/mlx_tts_impl.py +94 -0
- nexaai/tts_impl/pybind_tts_impl.py +43 -0
- nexaai/utils/decode.py +18 -0
- nexaai/utils/manifest_utils.py +531 -0
- nexaai/utils/model_manager.py +1745 -0
- nexaai/utils/model_types.py +49 -0
- nexaai/utils/progress_tracker.py +389 -0
- nexaai/utils/quantization_utils.py +245 -0
- nexaai/vlm.py +130 -0
- nexaai/vlm_impl/__init__.py +0 -0
- nexaai/vlm_impl/mlx_vlm_impl.py +259 -0
- nexaai/vlm_impl/pybind_vlm_impl.py +275 -0
- nexaai-1.0.29.dist-info/METADATA +35 -0
- nexaai-1.0.29.dist-info/RECORD +580 -0
- nexaai-1.0.29.dist-info/WHEEL +5 -0
- nexaai-1.0.29.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Callable, Optional, Union
|
|
5
|
+
|
|
6
|
+
import mlx.core as mx
|
|
7
|
+
import mlx.nn as nn
|
|
8
|
+
from dacite import from_dict
|
|
9
|
+
from mlx.utils import tree_flatten, tree_unflatten
|
|
10
|
+
import numpy as np
|
|
11
|
+
|
|
12
|
+
from mlx_audio.stt.models.parakeet import tokenizer
|
|
13
|
+
from mlx_audio.stt.models.parakeet.alignment import (
|
|
14
|
+
AlignedResult,
|
|
15
|
+
AlignedToken,
|
|
16
|
+
merge_longest_common_subsequence,
|
|
17
|
+
merge_longest_contiguous,
|
|
18
|
+
sentences_to_result,
|
|
19
|
+
tokens_to_sentences,
|
|
20
|
+
)
|
|
21
|
+
from mlx_audio.stt.models.parakeet.audio import PreprocessArgs, log_mel_spectrogram
|
|
22
|
+
from mlx_audio.stt.models.parakeet.conformer import Conformer, ConformerArgs
|
|
23
|
+
from mlx_audio.stt.models.parakeet.ctc import (
|
|
24
|
+
AuxCTCArgs,
|
|
25
|
+
ConvASRDecoder,
|
|
26
|
+
ConvASRDecoderArgs,
|
|
27
|
+
)
|
|
28
|
+
from mlx_audio.stt.models.parakeet.rnnt import (
|
|
29
|
+
JointArgs,
|
|
30
|
+
JointNetwork,
|
|
31
|
+
PredictArgs,
|
|
32
|
+
PredictNetwork,
|
|
33
|
+
)
|
|
34
|
+
from mlx_audio.stt.utils import load_audio
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass
|
|
38
|
+
class PreprocessArgs:
|
|
39
|
+
sample_rate: int
|
|
40
|
+
normalize: str
|
|
41
|
+
window_size: float
|
|
42
|
+
window_stride: float
|
|
43
|
+
window: str
|
|
44
|
+
features: int
|
|
45
|
+
n_fft: int
|
|
46
|
+
dither: float
|
|
47
|
+
pad_to: int = 0
|
|
48
|
+
pad_value: float = 0
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def win_length(self) -> int:
|
|
52
|
+
return int(self.window_size * self.sample_rate)
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def hop_length(self) -> int:
|
|
56
|
+
return int(self.window_stride * self.sample_rate)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass
|
|
60
|
+
class TDTDecodingArgs:
|
|
61
|
+
model_type: str
|
|
62
|
+
durations: list[int]
|
|
63
|
+
greedy: dict | None
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass
|
|
67
|
+
class RNNTDecodingArgs:
|
|
68
|
+
greedy: dict | None
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@dataclass
|
|
72
|
+
class CTCDecodingArgs:
|
|
73
|
+
greedy: dict | None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@dataclass
|
|
77
|
+
class ParakeetTDTArgs:
|
|
78
|
+
preprocessor: PreprocessArgs
|
|
79
|
+
encoder: ConformerArgs
|
|
80
|
+
decoder: PredictArgs
|
|
81
|
+
joint: JointArgs
|
|
82
|
+
decoding: TDTDecodingArgs
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class ParakeetRNNTArgs:
|
|
87
|
+
preprocessor: PreprocessArgs
|
|
88
|
+
encoder: ConformerArgs
|
|
89
|
+
decoder: PredictArgs
|
|
90
|
+
joint: JointArgs
|
|
91
|
+
decoding: RNNTDecodingArgs
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@dataclass
|
|
95
|
+
class ParakeetCTCArgs:
|
|
96
|
+
preprocessor: PreprocessArgs
|
|
97
|
+
encoder: ConformerArgs
|
|
98
|
+
decoder: ConvASRDecoderArgs
|
|
99
|
+
decoding: CTCDecodingArgs
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@dataclass
|
|
103
|
+
class ParakeetTDTCTCArgs(ParakeetTDTArgs):
|
|
104
|
+
aux_ctc: AuxCTCArgs
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class Model(nn.Module):
|
|
108
|
+
def __init__(self, preprocess_args: PreprocessArgs):
|
|
109
|
+
super().__init__()
|
|
110
|
+
|
|
111
|
+
self.preprocessor_config = preprocess_args
|
|
112
|
+
|
|
113
|
+
def decode(self, mel: mx.array) -> list[AlignedResult]:
|
|
114
|
+
"""
|
|
115
|
+
Decode mel spectrograms to produce transcriptions with the Parakeet model.
|
|
116
|
+
Handles batches and single input. Uses greedy decoding.
|
|
117
|
+
mel: [batch, sequence, mel_dim] or [sequence, mel_dim]
|
|
118
|
+
"""
|
|
119
|
+
raise NotImplementedError
|
|
120
|
+
|
|
121
|
+
def generate(
|
|
122
|
+
self,
|
|
123
|
+
audio: Union[str, Path, mx.array, np.ndarray],
|
|
124
|
+
*,
|
|
125
|
+
dtype: mx.Dtype = mx.bfloat16,
|
|
126
|
+
chunk_duration: Optional[float] = None,
|
|
127
|
+
overlap_duration: float = 15.0,
|
|
128
|
+
chunk_callback: Optional[Callable] = None,
|
|
129
|
+
) -> AlignedResult:
|
|
130
|
+
"""
|
|
131
|
+
Transcribe an audio file or audio data, with optional chunking for long files.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
audio: Path to the audio file OR audio data as array
|
|
135
|
+
dtype: Data type for processing
|
|
136
|
+
chunk_duration: If provided, splits audio into chunks of this length for processing
|
|
137
|
+
overlap_duration: Overlap between chunks (only used when chunking)
|
|
138
|
+
chunk_callback: A function to call back when chunk is processed, called with (current_position, total_position)
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
Transcription result with aligned tokens and sentences
|
|
142
|
+
"""
|
|
143
|
+
# Handle different input types
|
|
144
|
+
if isinstance(audio, (str, Path)):
|
|
145
|
+
# Load from file path
|
|
146
|
+
audio_path = Path(audio)
|
|
147
|
+
audio_data = load_audio(
|
|
148
|
+
audio_path, self.preprocessor_config.sample_rate, dtype=dtype
|
|
149
|
+
)
|
|
150
|
+
elif isinstance(audio, mx.array):
|
|
151
|
+
# Use provided MLX array directly
|
|
152
|
+
audio_data = audio.astype(dtype)
|
|
153
|
+
elif isinstance(audio, np.ndarray):
|
|
154
|
+
# Convert numpy array to MLX array
|
|
155
|
+
audio_data = mx.array(audio, dtype=dtype)
|
|
156
|
+
else:
|
|
157
|
+
raise ValueError(f"Unsupported audio input type: {type(audio)}")
|
|
158
|
+
|
|
159
|
+
if chunk_duration is None:
|
|
160
|
+
mel = log_mel_spectrogram(audio_data, self.preprocessor_config)
|
|
161
|
+
|
|
162
|
+
return self.decode(mel)[0]
|
|
163
|
+
|
|
164
|
+
audio_length_seconds = len(audio_data) / self.preprocessor_config.sample_rate
|
|
165
|
+
|
|
166
|
+
if audio_length_seconds <= chunk_duration:
|
|
167
|
+
mel = log_mel_spectrogram(audio_data, self.preprocessor_config)
|
|
168
|
+
|
|
169
|
+
return self.decode(mel)[0]
|
|
170
|
+
|
|
171
|
+
chunk_samples = int(chunk_duration * self.preprocessor_config.sample_rate)
|
|
172
|
+
overlap_samples = int(overlap_duration * self.preprocessor_config.sample_rate)
|
|
173
|
+
|
|
174
|
+
all_tokens = []
|
|
175
|
+
|
|
176
|
+
for start in range(0, len(audio_data), chunk_samples - overlap_samples):
|
|
177
|
+
end = min(start + chunk_samples, len(audio_data))
|
|
178
|
+
|
|
179
|
+
if chunk_callback is not None:
|
|
180
|
+
chunk_callback(end, len(audio_data))
|
|
181
|
+
|
|
182
|
+
chunk_audio = audio_data[start:end]
|
|
183
|
+
chunk_mel = log_mel_spectrogram(chunk_audio, self.preprocessor_config)
|
|
184
|
+
|
|
185
|
+
chunk_result = self.decode(chunk_mel)[0]
|
|
186
|
+
|
|
187
|
+
chunk_offset = start / self.preprocessor_config.sample_rate
|
|
188
|
+
for sentence in chunk_result.sentences:
|
|
189
|
+
for token in sentence.tokens:
|
|
190
|
+
token.start += chunk_offset
|
|
191
|
+
token.end = token.start + token.duration
|
|
192
|
+
|
|
193
|
+
chunk_tokens = []
|
|
194
|
+
for sentence in chunk_result.sentences:
|
|
195
|
+
chunk_tokens.extend(sentence.tokens)
|
|
196
|
+
|
|
197
|
+
if all_tokens:
|
|
198
|
+
try:
|
|
199
|
+
all_tokens = merge_longest_contiguous(
|
|
200
|
+
all_tokens, chunk_tokens, overlap_duration=overlap_duration
|
|
201
|
+
)
|
|
202
|
+
except RuntimeError:
|
|
203
|
+
all_tokens = merge_longest_common_subsequence(
|
|
204
|
+
all_tokens, chunk_tokens, overlap_duration=overlap_duration
|
|
205
|
+
)
|
|
206
|
+
else:
|
|
207
|
+
all_tokens = chunk_tokens
|
|
208
|
+
|
|
209
|
+
result = sentences_to_result(tokens_to_sentences(all_tokens))
|
|
210
|
+
|
|
211
|
+
# Clear cache after each segment to avoid memory leaks
|
|
212
|
+
mx.clear_cache()
|
|
213
|
+
|
|
214
|
+
return result
|
|
215
|
+
|
|
216
|
+
@classmethod
|
|
217
|
+
def from_config(cls, config: dict):
|
|
218
|
+
"""Loads model from config (randomized weights)"""
|
|
219
|
+
if (
|
|
220
|
+
config.get("target")
|
|
221
|
+
== "nemo.collections.asr.models.rnnt_bpe_models.EncDecRNNTBPEModel"
|
|
222
|
+
and config.get("model_defaults", {}).get("tdt_durations") is not None
|
|
223
|
+
):
|
|
224
|
+
cfg = from_dict(ParakeetTDTArgs, config)
|
|
225
|
+
model = ParakeetTDT(cfg)
|
|
226
|
+
elif (
|
|
227
|
+
config.get("target")
|
|
228
|
+
== "nemo.collections.asr.models.hybrid_rnnt_ctc_bpe_models.EncDecHybridRNNTCTCBPEModel"
|
|
229
|
+
and config.get("model_defaults", {}).get("tdt_durations") is not None
|
|
230
|
+
):
|
|
231
|
+
cfg = from_dict(ParakeetTDTCTCArgs, config)
|
|
232
|
+
model = ParakeetTDTCTC(cfg)
|
|
233
|
+
elif (
|
|
234
|
+
config.get("target")
|
|
235
|
+
== "nemo.collections.asr.models.rnnt_bpe_models.EncDecRNNTBPEModel"
|
|
236
|
+
and config.get("model_defaults", {}).get("tdt_durations") is None
|
|
237
|
+
):
|
|
238
|
+
cfg = from_dict(ParakeetRNNTArgs, config)
|
|
239
|
+
model = ParakeetRNNT(cfg)
|
|
240
|
+
elif (
|
|
241
|
+
config.get("target")
|
|
242
|
+
== "nemo.collections.asr.models.ctc_bpe_models.EncDecCTCModelBPE"
|
|
243
|
+
):
|
|
244
|
+
cfg = from_dict(ParakeetCTCArgs, config)
|
|
245
|
+
model = ParakeetCTC(cfg)
|
|
246
|
+
else:
|
|
247
|
+
raise ValueError("Model is not supported yet!")
|
|
248
|
+
|
|
249
|
+
model.eval() # prevents layernorm not computing correctly on inference!
|
|
250
|
+
|
|
251
|
+
return model
|
|
252
|
+
|
|
253
|
+
@classmethod
|
|
254
|
+
def from_pretrained(cls, model_path: str, *, dtype: mx.Dtype = mx.bfloat16):
|
|
255
|
+
"""Loads model from local directory"""
|
|
256
|
+
|
|
257
|
+
model_path = Path(model_path)
|
|
258
|
+
if not model_path.exists():
|
|
259
|
+
raise FileNotFoundError(f"Model directory not found: {model_path}")
|
|
260
|
+
|
|
261
|
+
config_path = model_path / "config.json"
|
|
262
|
+
if not config_path.exists():
|
|
263
|
+
raise FileNotFoundError(f"config.json not found in {model_path}")
|
|
264
|
+
|
|
265
|
+
weight_path = model_path / "model.safetensors"
|
|
266
|
+
if not weight_path.exists():
|
|
267
|
+
raise FileNotFoundError(f"model.safetensors not found in {model_path}")
|
|
268
|
+
|
|
269
|
+
config = json.load(open(config_path, "r"))
|
|
270
|
+
weight = str(weight_path)
|
|
271
|
+
|
|
272
|
+
model = cls.from_config(config)
|
|
273
|
+
model.load_weights(weight)
|
|
274
|
+
|
|
275
|
+
# cast dtype
|
|
276
|
+
curr_weights = dict(tree_flatten(model.parameters()))
|
|
277
|
+
curr_weights = [(k, v.astype(dtype)) for k, v in curr_weights.items()]
|
|
278
|
+
model.update(tree_unflatten(curr_weights))
|
|
279
|
+
|
|
280
|
+
return model
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
class ParakeetTDT(Model):
|
|
284
|
+
def __init__(self, args: ParakeetTDTArgs):
|
|
285
|
+
super().__init__(args.preprocessor)
|
|
286
|
+
|
|
287
|
+
assert args.decoding.model_type == "tdt", "Model must be a TDT model"
|
|
288
|
+
|
|
289
|
+
self.encoder_config = args.encoder
|
|
290
|
+
|
|
291
|
+
self.vocabulary = args.joint.vocabulary
|
|
292
|
+
self.durations = args.decoding.durations
|
|
293
|
+
self.max_symbols: int | None = (
|
|
294
|
+
args.decoding.greedy.get("max_symbols", None)
|
|
295
|
+
if args.decoding.greedy
|
|
296
|
+
else None
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
self.encoder = Conformer(args.encoder)
|
|
300
|
+
self.decoder = PredictNetwork(args.decoder)
|
|
301
|
+
self.joint = JointNetwork(args.joint)
|
|
302
|
+
|
|
303
|
+
def decode(self, mel: mx.array) -> list[AlignedResult]:
|
|
304
|
+
"""
|
|
305
|
+
Generate with skip token logic for the Parakeet model, handling batches and single input. Uses greedy decoding.
|
|
306
|
+
mel: [batch, sequence, mel_dim] or [sequence, mel_dim]
|
|
307
|
+
"""
|
|
308
|
+
batch_size: int = mel.shape[0]
|
|
309
|
+
if len(mel.shape) == 2:
|
|
310
|
+
batch_size = 1
|
|
311
|
+
mel = mx.expand_dims(mel, 0)
|
|
312
|
+
|
|
313
|
+
batch_features, lengths = self.encoder(mel)
|
|
314
|
+
mx.eval(batch_features, lengths)
|
|
315
|
+
|
|
316
|
+
results = []
|
|
317
|
+
for b in range(batch_size):
|
|
318
|
+
features = batch_features[b : b + 1]
|
|
319
|
+
max_length = int(lengths[b])
|
|
320
|
+
|
|
321
|
+
last_token = len(
|
|
322
|
+
self.vocabulary
|
|
323
|
+
) # In TDT, space token is always len(vocab)
|
|
324
|
+
hypothesis = []
|
|
325
|
+
|
|
326
|
+
time = 0
|
|
327
|
+
new_symbols = 0
|
|
328
|
+
decoder_hidden = None
|
|
329
|
+
|
|
330
|
+
while time < max_length:
|
|
331
|
+
feature = features[:, time : time + 1]
|
|
332
|
+
|
|
333
|
+
current_token = (
|
|
334
|
+
mx.array([[last_token]], dtype=mx.int32)
|
|
335
|
+
if last_token != len(self.vocabulary)
|
|
336
|
+
else None
|
|
337
|
+
)
|
|
338
|
+
decoder_output, (hidden, cell) = self.decoder(
|
|
339
|
+
current_token, decoder_hidden
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
# cast
|
|
343
|
+
decoder_output = decoder_output.astype(feature.dtype)
|
|
344
|
+
proposed_decoder_hidden = (
|
|
345
|
+
hidden.astype(feature.dtype),
|
|
346
|
+
cell.astype(feature.dtype),
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
joint_output = self.joint(feature, decoder_output)
|
|
350
|
+
|
|
351
|
+
pred_token = mx.argmax(
|
|
352
|
+
joint_output[0, 0, :, : len(self.vocabulary) + 1]
|
|
353
|
+
)
|
|
354
|
+
decision = mx.argmax(joint_output[0, 0, :, len(self.vocabulary) + 1 :])
|
|
355
|
+
|
|
356
|
+
if pred_token != len(self.vocabulary):
|
|
357
|
+
hypothesis.append(
|
|
358
|
+
AlignedToken(
|
|
359
|
+
int(pred_token),
|
|
360
|
+
start=time
|
|
361
|
+
* self.encoder_config.subsampling_factor
|
|
362
|
+
/ self.preprocessor_config.sample_rate
|
|
363
|
+
* self.preprocessor_config.hop_length, # hop
|
|
364
|
+
duration=self.durations[int(decision)]
|
|
365
|
+
* self.encoder_config.subsampling_factor
|
|
366
|
+
/ self.preprocessor_config.sample_rate
|
|
367
|
+
* self.preprocessor_config.hop_length, # hop
|
|
368
|
+
text=tokenizer.decode([int(pred_token)], self.vocabulary),
|
|
369
|
+
)
|
|
370
|
+
)
|
|
371
|
+
last_token = int(pred_token)
|
|
372
|
+
decoder_hidden = proposed_decoder_hidden
|
|
373
|
+
|
|
374
|
+
time += self.durations[int(decision)]
|
|
375
|
+
new_symbols += 1
|
|
376
|
+
|
|
377
|
+
if self.durations[int(decision)] != 0:
|
|
378
|
+
new_symbols = 0
|
|
379
|
+
else:
|
|
380
|
+
if self.max_symbols is not None and self.max_symbols <= new_symbols:
|
|
381
|
+
time += 1
|
|
382
|
+
new_symbols = 0
|
|
383
|
+
|
|
384
|
+
result = sentences_to_result(tokens_to_sentences(hypothesis))
|
|
385
|
+
results.append(result)
|
|
386
|
+
|
|
387
|
+
return results
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
class ParakeetRNNT(Model):
|
|
391
|
+
def __init__(self, args: ParakeetRNNTArgs):
|
|
392
|
+
super().__init__(args.preprocessor)
|
|
393
|
+
|
|
394
|
+
self.encoder_config = args.encoder
|
|
395
|
+
|
|
396
|
+
self.vocabulary = args.joint.vocabulary
|
|
397
|
+
self.max_symbols: int | None = (
|
|
398
|
+
args.decoding.greedy.get("max_symbols", None)
|
|
399
|
+
if args.decoding.greedy
|
|
400
|
+
else None
|
|
401
|
+
)
|
|
402
|
+
|
|
403
|
+
self.encoder = Conformer(args.encoder)
|
|
404
|
+
self.decoder = PredictNetwork(args.decoder)
|
|
405
|
+
self.joint = JointNetwork(args.joint)
|
|
406
|
+
|
|
407
|
+
def decode(self, mel: mx.array) -> list[AlignedResult]:
|
|
408
|
+
"""
|
|
409
|
+
Generate with skip token logic for the Parakeet model, handling batches and single input. Uses greedy decoding.
|
|
410
|
+
mel: [batch, sequence, mel_dim] or [sequence, mel_dim]
|
|
411
|
+
"""
|
|
412
|
+
batch_size: int = mel.shape[0]
|
|
413
|
+
if len(mel.shape) == 2:
|
|
414
|
+
batch_size = 1
|
|
415
|
+
mel = mx.expand_dims(mel, 0)
|
|
416
|
+
|
|
417
|
+
batch_features, lengths = self.encoder(mel)
|
|
418
|
+
mx.eval(batch_features, lengths)
|
|
419
|
+
|
|
420
|
+
results = []
|
|
421
|
+
for b in range(batch_size):
|
|
422
|
+
features = batch_features[b : b + 1]
|
|
423
|
+
max_length = int(lengths[b])
|
|
424
|
+
|
|
425
|
+
last_token = len(self.vocabulary)
|
|
426
|
+
hypothesis = []
|
|
427
|
+
|
|
428
|
+
time = 0
|
|
429
|
+
new_symbols = 0
|
|
430
|
+
decoder_hidden = None
|
|
431
|
+
|
|
432
|
+
while time < max_length:
|
|
433
|
+
feature = features[:, time : time + 1]
|
|
434
|
+
|
|
435
|
+
current_token = (
|
|
436
|
+
mx.array([[last_token]], dtype=mx.int32)
|
|
437
|
+
if last_token != len(self.vocabulary)
|
|
438
|
+
else None
|
|
439
|
+
)
|
|
440
|
+
decoder_output, (hidden, cell) = self.decoder(
|
|
441
|
+
current_token, decoder_hidden
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
# cast
|
|
445
|
+
decoder_output = decoder_output.astype(feature.dtype)
|
|
446
|
+
proposed_decoder_hidden = (
|
|
447
|
+
hidden.astype(feature.dtype),
|
|
448
|
+
cell.astype(feature.dtype),
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
joint_output = self.joint(feature, decoder_output)
|
|
452
|
+
|
|
453
|
+
pred_token = mx.argmax(joint_output)
|
|
454
|
+
|
|
455
|
+
if pred_token != len(self.vocabulary):
|
|
456
|
+
hypothesis.append(
|
|
457
|
+
AlignedToken(
|
|
458
|
+
int(pred_token),
|
|
459
|
+
start=time
|
|
460
|
+
* self.encoder_config.subsampling_factor
|
|
461
|
+
/ self.preprocessor_config.sample_rate
|
|
462
|
+
* self.preprocessor_config.hop_length, # hop
|
|
463
|
+
duration=1
|
|
464
|
+
* self.encoder_config.subsampling_factor
|
|
465
|
+
/ self.preprocessor_config.sample_rate
|
|
466
|
+
* self.preprocessor_config.hop_length, # hop
|
|
467
|
+
text=tokenizer.decode([int(pred_token)], self.vocabulary),
|
|
468
|
+
)
|
|
469
|
+
)
|
|
470
|
+
last_token = int(pred_token)
|
|
471
|
+
decoder_hidden = proposed_decoder_hidden
|
|
472
|
+
|
|
473
|
+
new_symbols += 1
|
|
474
|
+
if self.max_symbols is not None and self.max_symbols <= new_symbols:
|
|
475
|
+
time += 1
|
|
476
|
+
new_symbols = 0
|
|
477
|
+
else:
|
|
478
|
+
time += 1
|
|
479
|
+
new_symbols = 0
|
|
480
|
+
|
|
481
|
+
result = sentences_to_result(tokens_to_sentences(hypothesis))
|
|
482
|
+
results.append(result)
|
|
483
|
+
|
|
484
|
+
return results
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
class ParakeetCTC(Model):
|
|
488
|
+
def __init__(self, args: ParakeetCTCArgs):
|
|
489
|
+
super().__init__(args.preprocessor)
|
|
490
|
+
|
|
491
|
+
self.encoder_config = args.encoder
|
|
492
|
+
|
|
493
|
+
self.vocabulary = args.decoder.vocabulary
|
|
494
|
+
|
|
495
|
+
self.encoder = Conformer(args.encoder)
|
|
496
|
+
self.decoder = ConvASRDecoder(args.decoder)
|
|
497
|
+
|
|
498
|
+
def decode(self, mel: mx.array) -> list[AlignedResult]:
|
|
499
|
+
"""
|
|
500
|
+
Generate with CTC decoding for the Parakeet model, handling batches and single input. Uses greedy decoding.
|
|
501
|
+
mel: [batch, sequence, mel_dim] or [sequence, mel_dim]
|
|
502
|
+
"""
|
|
503
|
+
batch_size: int = mel.shape[0]
|
|
504
|
+
if len(mel.shape) == 2:
|
|
505
|
+
batch_size = 1
|
|
506
|
+
mel = mx.expand_dims(mel, 0)
|
|
507
|
+
|
|
508
|
+
batch_features, lengths = self.encoder(mel)
|
|
509
|
+
logits = self.decoder(batch_features)
|
|
510
|
+
mx.eval(logits, lengths)
|
|
511
|
+
|
|
512
|
+
results = []
|
|
513
|
+
for b in range(batch_size):
|
|
514
|
+
features_len = int(lengths[b])
|
|
515
|
+
predictions = logits[b, :features_len]
|
|
516
|
+
best_tokens = mx.argmax(predictions, axis=1)
|
|
517
|
+
|
|
518
|
+
hypothesis = []
|
|
519
|
+
token_boundaries = []
|
|
520
|
+
prev_token = -1
|
|
521
|
+
|
|
522
|
+
for t, token_id in enumerate(best_tokens):
|
|
523
|
+
token_idx = int(token_id)
|
|
524
|
+
|
|
525
|
+
if token_idx == len(self.vocabulary):
|
|
526
|
+
continue
|
|
527
|
+
|
|
528
|
+
if token_idx == prev_token:
|
|
529
|
+
continue
|
|
530
|
+
|
|
531
|
+
if prev_token != -1:
|
|
532
|
+
token_start_time = (
|
|
533
|
+
token_boundaries[-1][0]
|
|
534
|
+
* self.encoder_config.subsampling_factor
|
|
535
|
+
/ self.preprocessor_config.sample_rate
|
|
536
|
+
* self.preprocessor_config.hop_length
|
|
537
|
+
)
|
|
538
|
+
|
|
539
|
+
token_end_time = (
|
|
540
|
+
t
|
|
541
|
+
* self.encoder_config.subsampling_factor
|
|
542
|
+
/ self.preprocessor_config.sample_rate
|
|
543
|
+
* self.preprocessor_config.hop_length
|
|
544
|
+
)
|
|
545
|
+
|
|
546
|
+
token_duration = token_end_time - token_start_time
|
|
547
|
+
|
|
548
|
+
hypothesis.append(
|
|
549
|
+
AlignedToken(
|
|
550
|
+
prev_token,
|
|
551
|
+
start=token_start_time,
|
|
552
|
+
duration=token_duration,
|
|
553
|
+
text=tokenizer.decode([prev_token], self.vocabulary),
|
|
554
|
+
)
|
|
555
|
+
)
|
|
556
|
+
|
|
557
|
+
token_boundaries.append((t, None))
|
|
558
|
+
prev_token = token_idx
|
|
559
|
+
|
|
560
|
+
if prev_token != -1:
|
|
561
|
+
last_non_blank = features_len - 1
|
|
562
|
+
for t in range(features_len - 1, token_boundaries[-1][0], -1):
|
|
563
|
+
if int(best_tokens[t]) != len(self.vocabulary):
|
|
564
|
+
last_non_blank = t
|
|
565
|
+
break
|
|
566
|
+
|
|
567
|
+
token_start_time = (
|
|
568
|
+
token_boundaries[-1][0]
|
|
569
|
+
* self.encoder_config.subsampling_factor
|
|
570
|
+
/ self.preprocessor_config.sample_rate
|
|
571
|
+
* self.preprocessor_config.hop_length
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
token_end_time = (
|
|
575
|
+
(last_non_blank + 1)
|
|
576
|
+
* self.encoder_config.subsampling_factor
|
|
577
|
+
/ self.preprocessor_config.sample_rate
|
|
578
|
+
* self.preprocessor_config.hop_length
|
|
579
|
+
)
|
|
580
|
+
|
|
581
|
+
token_duration = token_end_time - token_start_time
|
|
582
|
+
|
|
583
|
+
hypothesis.append(
|
|
584
|
+
AlignedToken(
|
|
585
|
+
prev_token,
|
|
586
|
+
start=token_start_time,
|
|
587
|
+
duration=token_duration,
|
|
588
|
+
text=tokenizer.decode([prev_token], self.vocabulary),
|
|
589
|
+
)
|
|
590
|
+
)
|
|
591
|
+
|
|
592
|
+
result = sentences_to_result(tokens_to_sentences(hypothesis))
|
|
593
|
+
results.append(result)
|
|
594
|
+
|
|
595
|
+
return results
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
class ParakeetTDTCTC(ParakeetTDT):
|
|
599
|
+
"""Has ConvASRDecoder decoder in `.ctc_decoder` but `.generate` uses TDT decoder all the times (Please open an issue if you need CTC decoder use-case!)"""
|
|
600
|
+
|
|
601
|
+
def __init__(self, args: ParakeetTDTCTCArgs):
|
|
602
|
+
super().__init__(args)
|
|
603
|
+
|
|
604
|
+
self.ctc_decoder = ConvASRDecoder(args.aux_ctc.decoder)
|