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
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .models import DAC, Encodec, Mimi, Vocos
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .bigvgan import BigVGAN, BigVGANConfig
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import mlx.core as mx
|
|
2
|
+
import mlx.nn as nn
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Snake(nn.Module):
|
|
6
|
+
def __init__(
|
|
7
|
+
self, in_features: int, alpha: float = 1.0, alpha_logscale: bool = False
|
|
8
|
+
):
|
|
9
|
+
super().__init__()
|
|
10
|
+
|
|
11
|
+
self.alpha_logscale = alpha_logscale
|
|
12
|
+
|
|
13
|
+
self.alpha = (
|
|
14
|
+
mx.zeros(in_features) if alpha_logscale else mx.ones(in_features)
|
|
15
|
+
) * alpha
|
|
16
|
+
|
|
17
|
+
def __call__(self, x: mx.array):
|
|
18
|
+
alpha = self.alpha[None, :, None]
|
|
19
|
+
if self.alpha_logscale:
|
|
20
|
+
alpha = mx.exp(alpha)
|
|
21
|
+
|
|
22
|
+
x += (1.0 / (alpha + 1e-9)) * mx.power(mx.sin(x * alpha), 2)
|
|
23
|
+
|
|
24
|
+
return x
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class SnakeBeta(nn.Module):
|
|
28
|
+
def __init__(
|
|
29
|
+
self, in_features: int, alpha: float = 1.0, alpha_logscale: bool = False
|
|
30
|
+
):
|
|
31
|
+
super().__init__()
|
|
32
|
+
|
|
33
|
+
self.alpha_logscale = alpha_logscale
|
|
34
|
+
|
|
35
|
+
self.alpha = (
|
|
36
|
+
mx.zeros(in_features) if alpha_logscale else mx.ones(in_features)
|
|
37
|
+
) * alpha
|
|
38
|
+
self.beta = (
|
|
39
|
+
mx.zeros(in_features) if alpha_logscale else mx.ones(in_features)
|
|
40
|
+
) * alpha
|
|
41
|
+
|
|
42
|
+
def __call__(self, x: mx.array):
|
|
43
|
+
alpha = self.alpha[None, None, :]
|
|
44
|
+
beta = self.beta[None, None, :]
|
|
45
|
+
if self.alpha_logscale:
|
|
46
|
+
alpha = mx.exp(alpha)
|
|
47
|
+
beta = mx.exp(beta)
|
|
48
|
+
|
|
49
|
+
x += (1.0 / (beta + 1e-9)) * mx.power(mx.sin(x * alpha), 2)
|
|
50
|
+
|
|
51
|
+
return x
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import mlx.core as mx
|
|
2
|
+
import mlx.nn as nn
|
|
3
|
+
from typing_extensions import Literal
|
|
4
|
+
|
|
5
|
+
from mlx_audio.codec.models.bigvgan.activation import Snake, SnakeBeta
|
|
6
|
+
from mlx_audio.codec.models.bigvgan.conv import WNConv1d
|
|
7
|
+
from mlx_audio.codec.models.bigvgan.resample import Activation1d
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AMPBlock1(nn.Module):
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
channels: int,
|
|
14
|
+
snake_logscale: bool,
|
|
15
|
+
activation: Literal["snake", "snakebeta"],
|
|
16
|
+
kernel_size=3,
|
|
17
|
+
dilation: list[int] = [1, 3, 5],
|
|
18
|
+
):
|
|
19
|
+
super().__init__()
|
|
20
|
+
|
|
21
|
+
self.convs1 = [
|
|
22
|
+
WNConv1d(
|
|
23
|
+
channels,
|
|
24
|
+
channels,
|
|
25
|
+
kernel_size,
|
|
26
|
+
stride=1,
|
|
27
|
+
dilation=d,
|
|
28
|
+
padding=((kernel_size - 1) * d) // 2,
|
|
29
|
+
)
|
|
30
|
+
for d in dilation
|
|
31
|
+
]
|
|
32
|
+
self.convs2 = [
|
|
33
|
+
WNConv1d(
|
|
34
|
+
channels,
|
|
35
|
+
channels,
|
|
36
|
+
kernel_size,
|
|
37
|
+
stride=1,
|
|
38
|
+
dilation=1,
|
|
39
|
+
padding=(kernel_size - 1) // 2,
|
|
40
|
+
)
|
|
41
|
+
for _ in dilation
|
|
42
|
+
]
|
|
43
|
+
self.activations = [
|
|
44
|
+
Activation1d(
|
|
45
|
+
Snake(channels, alpha_logscale=snake_logscale)
|
|
46
|
+
if activation == "snake"
|
|
47
|
+
else SnakeBeta(channels, alpha_logscale=snake_logscale)
|
|
48
|
+
)
|
|
49
|
+
for _ in range(len(dilation) * 2)
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
def __call__(self, x: mx.array):
|
|
53
|
+
for conv1, conv2, activation1, activation2 in zip(
|
|
54
|
+
self.convs1, self.convs2, self.activations[::2], self.activations[1::2]
|
|
55
|
+
):
|
|
56
|
+
x = x + conv2(activation2(conv1(activation1(x))))
|
|
57
|
+
|
|
58
|
+
return x
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class AMPBlock2(nn.Module):
|
|
62
|
+
def __init__(
|
|
63
|
+
self,
|
|
64
|
+
channels: int,
|
|
65
|
+
snake_logscale: bool,
|
|
66
|
+
activation: Literal["snake", "snakebeta"],
|
|
67
|
+
kernel_size=3,
|
|
68
|
+
dilation: list[int] = [1, 3, 5],
|
|
69
|
+
):
|
|
70
|
+
super().__init__()
|
|
71
|
+
|
|
72
|
+
self.convs = [
|
|
73
|
+
WNConv1d(
|
|
74
|
+
channels,
|
|
75
|
+
channels,
|
|
76
|
+
kernel_size,
|
|
77
|
+
stride=1,
|
|
78
|
+
dilation=d,
|
|
79
|
+
padding=((kernel_size - 1) * d) // 2,
|
|
80
|
+
)
|
|
81
|
+
for d in dilation
|
|
82
|
+
]
|
|
83
|
+
self.activations = [
|
|
84
|
+
Activation1d(
|
|
85
|
+
Snake(channels, alpha_logscale=snake_logscale)
|
|
86
|
+
if activation == "snake"
|
|
87
|
+
else SnakeBeta(channels, alpha_logscale=snake_logscale)
|
|
88
|
+
)
|
|
89
|
+
for _ in dilation
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
def __call__(self, x: mx.array):
|
|
93
|
+
for conv, activation in zip(self.convs, self.activations):
|
|
94
|
+
x = x + conv(activation(x))
|
|
95
|
+
|
|
96
|
+
return x
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
import mlx.core as mx
|
|
5
|
+
import mlx.nn as nn
|
|
6
|
+
from mlx.utils import tree_flatten
|
|
7
|
+
|
|
8
|
+
from mlx_audio.codec.models.bigvgan.activation import Snake, SnakeBeta
|
|
9
|
+
from mlx_audio.codec.models.bigvgan.amp import AMPBlock1, AMPBlock2
|
|
10
|
+
from mlx_audio.codec.models.bigvgan.conv import WNConv1d, WNConvTranspose1d
|
|
11
|
+
from mlx_audio.codec.models.bigvgan.resample import Activation1d
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class BigVGANConfig:
|
|
16
|
+
num_mels: int
|
|
17
|
+
upsample_rates: list[int]
|
|
18
|
+
upsample_kernel_sizes: list[int]
|
|
19
|
+
upsample_initial_channel: int
|
|
20
|
+
resblock: Literal["1", "2"]
|
|
21
|
+
resblock_kernel_sizes: list[int]
|
|
22
|
+
resblock_dilation_sizes: list[list[int]]
|
|
23
|
+
activation: Literal["snakebeta", "snake"]
|
|
24
|
+
snake_logscale: bool
|
|
25
|
+
use_bias_at_final: bool = True # compatability
|
|
26
|
+
use_tanh_at_final: bool = True # compatability
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class BigVGAN(nn.Module):
|
|
30
|
+
def __init__(self, config: BigVGANConfig):
|
|
31
|
+
super().__init__()
|
|
32
|
+
|
|
33
|
+
self.num_kernels = len(config.resblock_kernel_sizes)
|
|
34
|
+
self.num_upsamples = len(config.upsample_rates)
|
|
35
|
+
self.use_tanh_at_final = config.use_tanh_at_final
|
|
36
|
+
|
|
37
|
+
self.conv_pre = WNConv1d(
|
|
38
|
+
config.num_mels, config.upsample_initial_channel, 7, 1, 3
|
|
39
|
+
)
|
|
40
|
+
self.ups = [
|
|
41
|
+
[
|
|
42
|
+
WNConvTranspose1d(
|
|
43
|
+
config.upsample_initial_channel // (2**i),
|
|
44
|
+
config.upsample_initial_channel // (2 ** (i + 1)),
|
|
45
|
+
k,
|
|
46
|
+
u,
|
|
47
|
+
padding=(k - u) // 2,
|
|
48
|
+
)
|
|
49
|
+
]
|
|
50
|
+
for i, (u, k) in enumerate(
|
|
51
|
+
zip(config.upsample_rates, config.upsample_kernel_sizes)
|
|
52
|
+
)
|
|
53
|
+
]
|
|
54
|
+
self.resblocks = [
|
|
55
|
+
(
|
|
56
|
+
AMPBlock1(
|
|
57
|
+
config.upsample_initial_channel // (2 ** (i + 1)),
|
|
58
|
+
config.snake_logscale,
|
|
59
|
+
config.activation,
|
|
60
|
+
k,
|
|
61
|
+
d,
|
|
62
|
+
)
|
|
63
|
+
if config.resblock == "1"
|
|
64
|
+
else AMPBlock2(
|
|
65
|
+
config.upsample_initial_channel // (2 ** (i + 1)),
|
|
66
|
+
config.snake_logscale,
|
|
67
|
+
config.activation,
|
|
68
|
+
k,
|
|
69
|
+
d,
|
|
70
|
+
)
|
|
71
|
+
)
|
|
72
|
+
for i in range(len(self.ups))
|
|
73
|
+
for j, (k, d) in enumerate(
|
|
74
|
+
zip(config.resblock_kernel_sizes, config.resblock_dilation_sizes)
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
self.activation_post = Activation1d(
|
|
78
|
+
Snake(
|
|
79
|
+
config.upsample_initial_channel // (2 ** len(self.ups)),
|
|
80
|
+
alpha_logscale=config.snake_logscale,
|
|
81
|
+
)
|
|
82
|
+
if config.activation == "snake"
|
|
83
|
+
else SnakeBeta(
|
|
84
|
+
config.upsample_initial_channel // (2 ** len(self.ups)),
|
|
85
|
+
alpha_logscale=config.snake_logscale,
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
self.conv_post = WNConv1d(
|
|
89
|
+
config.upsample_initial_channel // (2 ** len(self.ups)),
|
|
90
|
+
1,
|
|
91
|
+
7,
|
|
92
|
+
1,
|
|
93
|
+
padding=3,
|
|
94
|
+
bias=config.use_bias_at_final,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def __call__(
|
|
98
|
+
self, x: mx.array, *args, **kwargs
|
|
99
|
+
) -> mx.array: # (batch, num_mels, seq)
|
|
100
|
+
x = x.transpose(0, 2, 1)
|
|
101
|
+
|
|
102
|
+
x = self.conv_pre(x)
|
|
103
|
+
|
|
104
|
+
for step in range(self.num_upsamples):
|
|
105
|
+
for idx in range(len(self.ups[step])):
|
|
106
|
+
x = self.ups[step][idx](x)
|
|
107
|
+
|
|
108
|
+
xs = self.resblocks[step * self.num_kernels](x)
|
|
109
|
+
for idx in range(1, self.num_kernels):
|
|
110
|
+
xs += self.resblocks[step * self.num_kernels + idx](x)
|
|
111
|
+
|
|
112
|
+
x = xs / self.num_kernels
|
|
113
|
+
|
|
114
|
+
x = self.activation_post(x)
|
|
115
|
+
x = self.conv_post(x)
|
|
116
|
+
|
|
117
|
+
if self.use_tanh_at_final:
|
|
118
|
+
x = mx.tanh(x)
|
|
119
|
+
else:
|
|
120
|
+
x = mx.clip(x, -1.0, 1.0)
|
|
121
|
+
|
|
122
|
+
return x.transpose(0, 2, 1)
|
|
123
|
+
|
|
124
|
+
def sanitize(self, weights: dict[str, mx.array]):
|
|
125
|
+
new_weights = {}
|
|
126
|
+
curr_weights = dict(tree_flatten(self.parameters()))
|
|
127
|
+
|
|
128
|
+
for key, value in weights.items():
|
|
129
|
+
if "num_batches_tracked" in key:
|
|
130
|
+
continue
|
|
131
|
+
|
|
132
|
+
if "conv" in key or "lowpass.filter" in key or "upsample.filter" in key:
|
|
133
|
+
if value.ndim == 3:
|
|
134
|
+
if value.shape != curr_weights[key].shape:
|
|
135
|
+
value = value.transpose(0, 2, 1)
|
|
136
|
+
elif value.ndim == 4:
|
|
137
|
+
if value.shape != curr_weights[key].shape:
|
|
138
|
+
value = value.transpose(0, 2, 3, 1)
|
|
139
|
+
|
|
140
|
+
if "ups." in key:
|
|
141
|
+
if value.ndim == 3:
|
|
142
|
+
if value.shape != curr_weights[key].shape:
|
|
143
|
+
value = value.transpose(1, 2, 0)
|
|
144
|
+
|
|
145
|
+
new_weights[key] = value
|
|
146
|
+
|
|
147
|
+
del curr_weights
|
|
148
|
+
|
|
149
|
+
return new_weights
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
import mlx.core as mx
|
|
4
|
+
import mlx.nn as nn
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def normalize_weight(x, except_dim=0):
|
|
8
|
+
if x.ndim != 3:
|
|
9
|
+
raise ValueError("Input tensor must have 3 dimensions")
|
|
10
|
+
|
|
11
|
+
axes = tuple(i for i in range(x.ndim) if i != except_dim)
|
|
12
|
+
return mx.sqrt(mx.sum(mx.power(x, 2), axis=axes, keepdims=True))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class WNConv1d(nn.Module):
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
in_channels: int,
|
|
19
|
+
out_channels: int,
|
|
20
|
+
kernel_size: int,
|
|
21
|
+
stride: int = 1,
|
|
22
|
+
padding: int = 0,
|
|
23
|
+
dilation: int = 1,
|
|
24
|
+
groups: int = 1,
|
|
25
|
+
bias: bool = True,
|
|
26
|
+
):
|
|
27
|
+
super().__init__()
|
|
28
|
+
|
|
29
|
+
if bias:
|
|
30
|
+
self.bias = mx.zeros((out_channels,))
|
|
31
|
+
|
|
32
|
+
self.kernel_size = kernel_size
|
|
33
|
+
self.padding = padding
|
|
34
|
+
self.dilation = dilation
|
|
35
|
+
self.stride = stride
|
|
36
|
+
self.groups = groups
|
|
37
|
+
|
|
38
|
+
scale = math.sqrt(1 / (in_channels * kernel_size))
|
|
39
|
+
weight_init = mx.random.uniform(
|
|
40
|
+
low=-scale,
|
|
41
|
+
high=scale,
|
|
42
|
+
shape=(out_channels, kernel_size, in_channels),
|
|
43
|
+
)
|
|
44
|
+
self.weight_g = normalize_weight(weight_init)
|
|
45
|
+
self.weight_v = weight_init / (self.weight_g + 1e-12)
|
|
46
|
+
|
|
47
|
+
def _extra_repr(self):
|
|
48
|
+
return (
|
|
49
|
+
f"in_channels={self.weight_v.shape[2]}, out_channels={self.weight_v.shape[0]}, "
|
|
50
|
+
f"kernel_size={self.kernel_size}, stride={self.stride}, "
|
|
51
|
+
f"padding={self.padding}, dilation={self.dilation}, "
|
|
52
|
+
f"bias={'bias' in self}"
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def __call__(self, x):
|
|
56
|
+
weight = self.weight_g * self.weight_v / normalize_weight(self.weight_v)
|
|
57
|
+
y = mx.conv1d(x, weight, self.stride, self.padding, self.dilation, self.groups)
|
|
58
|
+
if "bias" in self:
|
|
59
|
+
y = y + self.bias
|
|
60
|
+
return y
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class WNConvTranspose1d(nn.Module):
|
|
64
|
+
def __init__(
|
|
65
|
+
self,
|
|
66
|
+
in_channels: int,
|
|
67
|
+
out_channels: int,
|
|
68
|
+
kernel_size: int,
|
|
69
|
+
stride: int = 1,
|
|
70
|
+
padding: int = 0,
|
|
71
|
+
dilation: int = 1,
|
|
72
|
+
output_padding: int = 0,
|
|
73
|
+
bias: bool = True,
|
|
74
|
+
):
|
|
75
|
+
super().__init__()
|
|
76
|
+
|
|
77
|
+
self.bias = mx.zeros((out_channels,)) if bias else None
|
|
78
|
+
|
|
79
|
+
self.kernel_size = kernel_size
|
|
80
|
+
self.padding = padding
|
|
81
|
+
self.dilation = dilation
|
|
82
|
+
self.stride = stride
|
|
83
|
+
self.output_padding = output_padding
|
|
84
|
+
|
|
85
|
+
scale = math.sqrt(1 / (in_channels * kernel_size))
|
|
86
|
+
weight_init = mx.random.uniform(
|
|
87
|
+
low=-scale,
|
|
88
|
+
high=scale,
|
|
89
|
+
shape=(out_channels, kernel_size, in_channels),
|
|
90
|
+
)
|
|
91
|
+
self.weight_g = normalize_weight(weight_init, except_dim=2)
|
|
92
|
+
self.weight_v = weight_init / (self.weight_g + 1e-12)
|
|
93
|
+
|
|
94
|
+
def _extra_repr(self):
|
|
95
|
+
return (
|
|
96
|
+
f"in_channels={self.weight_v.shape[2]}, out_channels={self.weight_v.shape[0]}, "
|
|
97
|
+
f"kernel_size={self.kernel_size}, stride={self.stride}, "
|
|
98
|
+
f"padding={self.padding}, dilation={self.dilation}, "
|
|
99
|
+
f"output_padding={self.output_padding}, bias={'bias' in self}"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
def __call__(self, x):
|
|
103
|
+
weight = (
|
|
104
|
+
self.weight_g
|
|
105
|
+
* self.weight_v
|
|
106
|
+
/ normalize_weight(self.weight_v, except_dim=2)
|
|
107
|
+
)
|
|
108
|
+
y = mx.conv_transpose1d(
|
|
109
|
+
x, weight, self.stride, self.padding, self.dilation, self.output_padding
|
|
110
|
+
)
|
|
111
|
+
nn.ConvTranspose1d
|
|
112
|
+
if self.bias is not None:
|
|
113
|
+
y = y + self.bias
|
|
114
|
+
return y
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import math
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
import mlx.core as mx
|
|
5
|
+
import mlx.nn as nn
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def sinc(x: mx.array):
|
|
10
|
+
return mx.where(
|
|
11
|
+
x == 0,
|
|
12
|
+
mx.array(1.0, dtype=x.dtype),
|
|
13
|
+
mx.sin(math.pi * x) / math.pi / x,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def kaiser_sinc_filter1d(
|
|
18
|
+
cutoff: float, half_width: float, kernel_size: int
|
|
19
|
+
) -> mx.array: # return filter [1,kernel_size,1]
|
|
20
|
+
even = kernel_size % 2 == 0
|
|
21
|
+
half_size = kernel_size // 2
|
|
22
|
+
|
|
23
|
+
# For kaiser window
|
|
24
|
+
delta_f = 4 * half_width
|
|
25
|
+
A = 2.285 * (half_size - 1) * math.pi * delta_f + 7.95
|
|
26
|
+
if A > 50.0:
|
|
27
|
+
beta = 0.1102 * (A - 8.7)
|
|
28
|
+
elif A >= 21.0:
|
|
29
|
+
beta = 0.5842 * (A - 21) ** 0.4 + 0.07886 * (A - 21.0)
|
|
30
|
+
else:
|
|
31
|
+
beta = 0.0
|
|
32
|
+
window = mx.array(np.kaiser(kernel_size, beta=beta))
|
|
33
|
+
|
|
34
|
+
# ratio = 0.5/cutoff -> 2 * cutoff = 1 / ratio
|
|
35
|
+
if even:
|
|
36
|
+
time = mx.arange(-half_size, half_size) + 0.5
|
|
37
|
+
else:
|
|
38
|
+
time = mx.arange(kernel_size) - half_size
|
|
39
|
+
if cutoff == 0:
|
|
40
|
+
filter = mx.zeros_like(time).reshape(1, kernel_size, 1)
|
|
41
|
+
else:
|
|
42
|
+
filter_ = 2 * cutoff * window * sinc(2 * cutoff * time)
|
|
43
|
+
filter_ /= filter_.sum()
|
|
44
|
+
filter = filter_.reshape(1, kernel_size, 1)
|
|
45
|
+
|
|
46
|
+
return filter
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class LowPassFilter1d(nn.Module):
|
|
50
|
+
def __init__(
|
|
51
|
+
self,
|
|
52
|
+
cutoff: float = 0.5,
|
|
53
|
+
half_width: float = 0.6,
|
|
54
|
+
stride: int = 1,
|
|
55
|
+
padding: bool = True,
|
|
56
|
+
padding_mode: str = "edge",
|
|
57
|
+
kernel_size: int = 12,
|
|
58
|
+
):
|
|
59
|
+
super().__init__()
|
|
60
|
+
|
|
61
|
+
if cutoff < -0.0:
|
|
62
|
+
raise ValueError("Minimum cutoff must be larger than zero.")
|
|
63
|
+
if cutoff > 0.5:
|
|
64
|
+
raise ValueError("A cutoff above 0.5 does not make sense.")
|
|
65
|
+
|
|
66
|
+
self.even = kernel_size % 2 == 0
|
|
67
|
+
self.stride = stride
|
|
68
|
+
|
|
69
|
+
self.pad_left = kernel_size // 2 - int(self.even)
|
|
70
|
+
self.pad_right = kernel_size // 2
|
|
71
|
+
self.padding = padding
|
|
72
|
+
self.padding_mode = padding_mode
|
|
73
|
+
|
|
74
|
+
self.filter = kaiser_sinc_filter1d(
|
|
75
|
+
cutoff, half_width, kernel_size
|
|
76
|
+
) # (1, kernel_size, 1)
|
|
77
|
+
mx.eval(self.filter)
|
|
78
|
+
|
|
79
|
+
def __call__(self, x: mx.array): # (b, t, c)
|
|
80
|
+
_, _, C = x.shape
|
|
81
|
+
|
|
82
|
+
if self.padding:
|
|
83
|
+
x = mx.pad(
|
|
84
|
+
x,
|
|
85
|
+
((0, 0), (self.pad_left, self.pad_right), (0, 0)),
|
|
86
|
+
mode=self.padding_mode,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
expanded_filter = mx.broadcast_to(self.filter, (C, *self.filter.shape[1:]))
|
|
90
|
+
|
|
91
|
+
out = mx.conv1d(
|
|
92
|
+
x,
|
|
93
|
+
expanded_filter,
|
|
94
|
+
stride=self.stride,
|
|
95
|
+
groups=C,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
return out
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class UpSample1d(nn.Module):
|
|
102
|
+
def __init__(self, ratio: int = 2, kernel_size: Optional[int] = None):
|
|
103
|
+
super().__init__()
|
|
104
|
+
|
|
105
|
+
self.ratio = ratio
|
|
106
|
+
self.kernel_size = (
|
|
107
|
+
int(6 * ratio // 2) * 2 if kernel_size is None else kernel_size
|
|
108
|
+
)
|
|
109
|
+
self.stride = ratio
|
|
110
|
+
|
|
111
|
+
self.pad = self.kernel_size // ratio - 1
|
|
112
|
+
self.pad_left = self.pad * self.stride + (self.kernel_size - self.stride) // 2
|
|
113
|
+
self.pad_right = (
|
|
114
|
+
self.pad * self.stride + (self.kernel_size - self.stride + 1) // 2
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
self.filter = kaiser_sinc_filter1d(
|
|
118
|
+
cutoff=0.5 / ratio, half_width=0.6 / ratio, kernel_size=self.kernel_size
|
|
119
|
+
)
|
|
120
|
+
mx.eval(self.filter)
|
|
121
|
+
|
|
122
|
+
def __call__(self, x: mx.array) -> mx.array: # (b, t, c)
|
|
123
|
+
_, _, C = x.shape
|
|
124
|
+
|
|
125
|
+
x = mx.pad(x, ((0, 0), (self.pad, self.pad), (0, 0)), mode="edge")
|
|
126
|
+
|
|
127
|
+
expanded_filter = mx.broadcast_to(self.filter, (C, *self.filter.shape[1:]))
|
|
128
|
+
|
|
129
|
+
x = self.ratio * mx.conv_transpose1d(
|
|
130
|
+
x,
|
|
131
|
+
expanded_filter,
|
|
132
|
+
stride=self.stride,
|
|
133
|
+
groups=C,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
return x[:, self.pad_left : -self.pad_right, :]
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class DownSample1d(nn.Module):
|
|
140
|
+
def __init__(self, ratio: int = 2, kernel_size: Optional[int] = None):
|
|
141
|
+
super().__init__()
|
|
142
|
+
self.ratio = ratio
|
|
143
|
+
self.kernel_size = (
|
|
144
|
+
int(6 * ratio // 2) * 2 if kernel_size is None else kernel_size
|
|
145
|
+
)
|
|
146
|
+
self.lowpass = LowPassFilter1d(
|
|
147
|
+
cutoff=0.5 / ratio,
|
|
148
|
+
half_width=0.6 / ratio,
|
|
149
|
+
stride=ratio,
|
|
150
|
+
kernel_size=self.kernel_size,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
def __call__(self, x: mx.array) -> mx.array: # (b, t, c)
|
|
154
|
+
return self.lowpass(x)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class Activation1d(nn.Module):
|
|
158
|
+
def __init__(
|
|
159
|
+
self,
|
|
160
|
+
activation: nn.Module,
|
|
161
|
+
up_ratio: int = 2,
|
|
162
|
+
down_ratio: int = 2,
|
|
163
|
+
up_kernel_size: int = 12,
|
|
164
|
+
down_kernel_size: int = 12,
|
|
165
|
+
):
|
|
166
|
+
super().__init__()
|
|
167
|
+
self.up_ratio = up_ratio
|
|
168
|
+
self.down_ratio = down_ratio
|
|
169
|
+
self.act = activation
|
|
170
|
+
self.upsample = UpSample1d(up_ratio, up_kernel_size)
|
|
171
|
+
self.downsample = DownSample1d(down_ratio, down_kernel_size)
|
|
172
|
+
|
|
173
|
+
def __call__(self, x):
|
|
174
|
+
x = self.upsample(x)
|
|
175
|
+
x = self.act(x)
|
|
176
|
+
x = self.downsample(x)
|
|
177
|
+
return x
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .dac import DAC
|