{"id":45461901,"url":"https://github.com/second-state/qwen3_asr_rs","last_synced_at":"2026-03-05T20:54:48.317Z","repository":{"id":339722835,"uuid":"1162745977","full_name":"second-state/qwen3_asr_rs","owner":"second-state","description":"Rust implementation of Qwen3-ASR automatic speech recognition","archived":false,"fork":false,"pushed_at":"2026-02-26T03:04:18.000Z","size":789,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-26T15:56:16.846Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/second-state.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-20T16:37:20.000Z","updated_at":"2026-02-26T03:04:21.000Z","dependencies_parsed_at":"2026-02-23T09:01:07.179Z","dependency_job_id":null,"html_url":"https://github.com/second-state/qwen3_asr_rs","commit_stats":null,"previous_names":["second-state/qwen3_asr_rs"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/second-state/qwen3_asr_rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fqwen3_asr_rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fqwen3_asr_rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fqwen3_asr_rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fqwen3_asr_rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/second-state","download_url":"https://codeload.github.com/second-state/qwen3_asr_rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fqwen3_asr_rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29896314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T12:09:13.686Z","status":"ssl_error","status_checked_at":"2026-02-27T12:09:13.282Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-22T08:05:12.158Z","updated_at":"2026-03-05T20:54:48.304Z","avatar_url":"https://github.com/second-state.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Qwen3 ASR -- Rust CLI tools\n\nPure Rust implementation of [Qwen3-ASR](https://github.com/QwenLM/Qwen3-ASR) automatic speech recognition. The project builds a cross-platform CLI tool suitable for agentic skills for AI agents and bots.\n\n- **asr** generates text from an input audio file (supports most codex and file formats)\n\nSupports two backends: **libtorch** (via the `tch` crate, cross-platform with optional CUDA) and **MLX** (Apple Silicon native via Metal GPU). Loads model weights directly from safetensors files and re-implements the complete neural network forward pass in Rust.\n\nLearn more:\n* [A Rust implementation / CLI](https://github.com/second-state/qwen3_tts_rs) for Qwen3's TTS (Text-to-Speech or speech synthesis) models\n* An OpenAI compatible [API server for audio / speech](https://github.com/second-state/qwen3_audio_api/tree/main/rust)\n* An OpenClaw SKILL for voice recognition. Copy and paste to your lobster to [install it](https://raw.githubusercontent.com/second-state/qwen3_asr_rs/refs/heads/main/skills/install.md)\n\n## Quick Start\n\nThe install script automatically detects your platform (macOS/Linux, CPU/CUDA GPU), downloads the correct release binary, model weights, and a sample audio file:\n\n```bash\ncurl -sSf https://raw.githubusercontent.com/second-state/qwen3_asr_rs/main/install.sh | bash\n```\n\nThe installer will prompt you to choose a model size (0.6B recommended) and, on Linux with an NVIDIA GPU, whether to use CUDA or CPU.\n\nOnce complete, run your first transcription:\n\n```bash\ncd qwen3_asr_rs\n./asr ./Qwen3-ASR-0.6B sample.wav\n```\n\nOutput:\n\n```\nLanguage: English\nText: Thank you for your contribution to the most recent issue of Computer.\n```\n\n## Architecture\n\nThe implementation ports the Qwen3-ASR encoder-decoder architecture from PyTorch/Transformers to Rust with libtorch (via the `tch` crate):\n\n- **Audio Encoder** (Whisper-style): 3x Conv2d downsampling → sinusoidal positional embeddings → 18 transformer encoder layers → output projection (896 → 1024)\n- **Text Decoder** (Qwen3): 28 transformer decoder layers with Grouped Query Attention (16 Q heads / 8 KV heads), QK-normalization, MRoPE (Multimodal Rotary Position Embeddings), and SwiGLU MLP\n- **Audio preprocessing**: FFmpeg decodes any audio format → resampled to mono 16kHz f32 → 128-bin log-mel spectrogram (Whisper-style)\n\n## Supported Models\n\n| Model | Parameters | HuggingFace |\n|-------|-----------|-------------|\n| Qwen3-ASR-0.6B | 0.6B | [Qwen/Qwen3-ASR-0.6B](https://huggingface.co/Qwen/Qwen3-ASR-0.6B) |\n| Qwen3-ASR-1.7B | 1.7B | [Qwen/Qwen3-ASR-1.7B](https://huggingface.co/Qwen/Qwen3-ASR-1.7B) |\n\n## Usage\n\n```bash\n# Basic transcription (auto-detect language)\nasr ./Qwen3-ASR-0.6B input.wav\n\n# Force language\nasr ./Qwen3-ASR-0.6B input.wav chinese\nasr ./Qwen3-ASR-0.6B input.wav english\n\n# Enable debug logging\nRUST_LOG=debug asr ./Qwen3-ASR-0.6B input.wav\n```\n\n### Output Format\n\n```\nLanguage: Chinese\nText: 你好世界\n```\n\n## Supported Languages\n\nQwen3-ASR supports 30 languages: Chinese, English, Cantonese, Arabic, German, French, Spanish, Portuguese, Indonesian, Italian, Korean, Russian, Thai, Vietnamese, Japanese, Turkish, Hindi, Malay, Dutch, Swedish, Danish, Finnish, Polish, Czech, Filipino, Persian, Greek, Romanian, Hungarian, Macedonian.\n\n## Build from Source\n\n### Prerequisites\n\nDownload model weights and generate the tokenizer:\n\n```bash\npip install huggingface_hub transformers\n\nhuggingface-cli download Qwen/Qwen3-ASR-0.6B --local-dir Qwen3-ASR-0.6B\n\npython -c \"\nfrom transformers import AutoTokenizer\ntok = AutoTokenizer.from_pretrained('Qwen3-ASR-0.6B', trust_remote_code=True)\ntok.backend_tokenizer.save('Qwen3-ASR-0.6B/tokenizer.json')\n\"\n```\n\n### Build for macOS (MLX)\n\nInstall dependencies:\n\n```bash\nbrew install ffmpeg\n```\n\nBuild:\n\n```bash\ngit submodule update --init --recursive\ncargo build --release --no-default-features --features mlx,build-ffmpeg\n```\n\n### Build for Linux (libtorch)\n\nDownload and extract libtorch for your platform from [libtorch-releases](https://github.com/second-state/libtorch-releases/releases/tag/v2.7.1):\n\n```bash\n# Linux x86_64 (CPU)\ncurl -LO https://github.com/second-state/libtorch-releases/releases/download/v2.7.1/libtorch-cxx11-abi-x86_64-2.7.1.tar.gz\ntar xzf libtorch-cxx11-abi-x86_64-2.7.1.tar.gz\n\n# Linux x86_64 (CUDA 12.6)\ncurl -LO https://github.com/second-state/libtorch-releases/releases/download/v2.7.1/libtorch-cxx11-abi-x86_64-cuda12.6-2.7.1.tar.gz\ntar xzf libtorch-cxx11-abi-x86_64-cuda12.6-2.7.1.tar.gz\n\n# Linux ARM64 (CPU)\ncurl -LO https://github.com/second-state/libtorch-releases/releases/download/v2.7.1/libtorch-cxx11-abi-aarch64-2.7.1.tar.gz\ntar xzf libtorch-cxx11-abi-aarch64-2.7.1.tar.gz\n\n# Linux ARM64 (CUDA 12.6 / Jetson)\ncurl -LO https://github.com/second-state/libtorch-releases/releases/download/v2.7.1/libtorch-cxx11-abi-aarch64-cuda12.6-2.7.1.tar.gz\ntar xzf libtorch-cxx11-abi-aarch64-cuda12.6-2.7.1.tar.gz\n```\n\nSet environment variables:\n\n```bash\nexport LIBTORCH=$(pwd)/libtorch\nexport LIBTORCH_BYPASS_VERSION_CHECK=1\n```\n\nInstall dependencies and build:\n\n```bash\nsudo apt-get install -y nasm pkg-config\ncargo build --release --features build-ffmpeg\n```\n\n## Project Structure\n\n```\nsrc/\n├── main.rs            # CLI binary entry point\n├── lib.rs             # Library module declarations\n├── tensor.rs          # Unified Tensor abstraction (tch/MLX backend)\n├── config.rs          # Model configuration (from config.json)\n├── error.rs           # Error types\n├── audio.rs           # FFmpeg-based audio loading and format conversion\n├── mel.rs             # Whisper-style mel spectrogram feature extraction\n├── weights.rs         # Safetensors weight loading (bf16 → f32 conversion)\n├── layers.rs          # Neural network building blocks (LayerNorm, RMSNorm,\n│                      #   attention, MLP, MRoPE, etc.)\n├── audio_encoder.rs   # Whisper-style audio encoder (Conv2d + Transformer)\n├── text_decoder.rs    # Qwen3 text decoder with KV cache\n├── tokenizer.rs       # HuggingFace tokenizer wrapper\n├── inference.rs       # End-to-end ASR inference pipeline\n└── backend/\n    └── mlx/           # Apple MLX backend (Metal GPU)\n        ├── ffi.rs     # Raw C FFI bindings to mlx-c\n        ├── array.rs   # Safe RAII MlxArray wrapper\n        ├── ops.rs     # Safe operation wrappers\n        ├── io.rs      # Safetensors loading via mlx-c\n        ├── signal.rs  # STFT, mel spectrogram signal processing\n        └── stream.rs  # Device/stream management\n```\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecond-state%2Fqwen3_asr_rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecond-state%2Fqwen3_asr_rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecond-state%2Fqwen3_asr_rs/lists"}