| --- |
| language: |
| - en |
| license: other |
| tags: |
| - wav2vec2 |
| - gguf |
| - asr |
| - speech |
| - audio |
| library_name: wav2vec2.cpp |
| base_model: |
| - facebook/wav2vec2-large-960h |
| --- |
| |
| # wav2vec2-large-960h |
|
|
| GGUF quantizations of [facebook/wav2vec2-large-960h](https://huggingface.co/facebook/wav2vec2-large-960h) for use with [wav2vec2.cpp](https://github.com/liodon-ai/wav2vec2.cpp). |
|
|
| ## Files |
|
|
| | Filename | Quant | Size | Precision | |
| |----------|-------|------|-----------| |
| | `model_f16.gguf` | F16 | 631 MB | ~fp16 (near-lossless) | |
| | `model_q8_0.gguf` | Q8_0 | 373 MB | 8-bit quantized linear layers | |
| | `model_q4_0.gguf` | Q4_0 | 222 MB | 4-bit quantized linear layers | |
|
|
| ## Parity vs HuggingFace Reference |
|
|
| Tested on 10 audio samples from LibriSpeech. |
|
|
| | Quant | Mean CER (vs HF) | Mean WER (vs HF) | Status | |
| |-------|-----------------|-----------------|--------| |
| | F16 | 0.14% | 0.83% | PASS | |
| | Q8_0 | 0.43% | 3.23% | PASS | |
| | Q4_0 | 0.67% | 2.59% | PASS | |
|
|
| CER/WER measured against HF model output (not ground truth) to isolate quantization error. |
|
|
| ## Usage |
|
|
| ### C++ CLI |
|
|
| ```bash |
| # Clone and build |
| git clone --recursive https://github.com/liodon-ai/wav2vec2.cpp |
| cd wav2vec2.cpp && mkdir build && cd build && cmake .. && make -j |
| |
| # Download and run |
| huggingface-cli download liodon-ai/wav2vec2-large-960h-GGUF model_q8_0.gguf --local-dir . |
| ./wav2vec2-cli -m model_q8_0.gguf -f audio.wav |
| |
| # With word timestamps |
| ./wav2vec2-cli -m model_q8_0.gguf -f audio.wav -w |
| |
| # SRT subtitle output |
| ./wav2vec2-cli -m model_q8_0.gguf -f audio.wav --format srt > output.srt |
| ``` |
|
|
| ### Python (via subprocess) |
|
|
| ```python |
| import subprocess, json |
| result = subprocess.run( |
| ['./wav2vec2-cli', '-m', 'model_q8_0.gguf', '-f', 'audio.wav', '--format', 'json'], |
| capture_output=True, text=True |
| ) |
| data = json.loads(result.stdout) |
| print(data['transcript']) |
| ``` |
|
|
| ## Source Model |
|
|
| - **Original**: [facebook/wav2vec2-large-960h](https://huggingface.co/facebook/wav2vec2-large-960h) |
| - **Architecture**: large-960h |
| - **Language**: en |
| - **Task**: Automatic Speech Recognition |
|
|
| ## Conversion |
|
|
| Converted using [wav2vec2.cpp](https://github.com/liodon-ai/wav2vec2.cpp) `scripts/convert_to_gguf.py`. |
|
|
| ```bash |
| python scripts/convert_to_gguf.py facebook/wav2vec2-large-960h model_f16.gguf --dtype f16 |
| python scripts/convert_to_gguf.py facebook/wav2vec2-large-960h model_q8_0.gguf --dtype q8_0 |
| python scripts/convert_to_gguf.py facebook/wav2vec2-large-960h model_q4_0.gguf --dtype q4_0 |
| ``` |
|
|
| ## License |
|
|
| Follows the license of the [source model](https://huggingface.co/facebook/wav2vec2-large-960h/blob/main/LICENSE). |
|
|