|
| 1 | +<!--Copyright 2025 The HuggingFace Inc. team. All rights reserved. |
| 2 | +
|
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 4 | +the License. You may obtain a copy of the License at |
| 5 | +
|
| 6 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +
|
| 8 | +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 9 | +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 10 | +specific language governing permissions and limitations under the License. |
| 11 | +
|
| 12 | +⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be |
| 13 | +rendered properly in your Markdown viewer. |
| 14 | +
|
| 15 | +--> |
| 16 | + |
| 17 | +<div class="flex flex-wrap space-x-1"> |
| 18 | +<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&logo=pytorch&logoColor=white"> |
| 19 | +<img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white"> |
| 20 | +</div> |
| 21 | + |
| 22 | +# LASR |
| 23 | + |
| 24 | +## Overview |
| 25 | + |
| 26 | +TODO |
| 27 | + |
| 28 | +## Usage |
| 29 | + |
| 30 | +### Basic usage |
| 31 | + |
| 32 | +<hfoptions id="usage"> |
| 33 | +<hfoption id="Pipeline"> |
| 34 | + |
| 35 | +```py |
| 36 | +from transformers import pipeline |
| 37 | + |
| 38 | +pipe = pipeline("automatic-speech-recognition", model="path/to/lasr-model") |
| 39 | +out = pipe("path/to/audio.mp3") |
| 40 | +print(out) |
| 41 | +``` |
| 42 | + |
| 43 | +</hfoption> |
| 44 | +<hfoption id="AutoModel"> |
| 45 | + |
| 46 | +```py |
| 47 | +from transformers import AutoModelForCTC, AutoProcessor |
| 48 | +from datasets import load_dataset, Audio |
| 49 | +import torch |
| 50 | + |
| 51 | +device = "cuda" if torch.cuda.is_available() else "cpu" |
| 52 | + |
| 53 | +processor = AutoProcessor.from_pretrained("path/to/lasr-model") |
| 54 | +model = AutoModelForCTC.from_pretrained("path/to/lasr-model", dtype="auto", device_map=device) |
| 55 | + |
| 56 | +ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation") |
| 57 | +ds = ds.cast_column("audio", Audio(sampling_rate=processor.feature_extractor.sampling_rate)) |
| 58 | +speech_samples = [el['array'] for el in ds["audio"][:5]] |
| 59 | + |
| 60 | +inputs = processor(speech_samples, sampling_rate=processor.feature_extractor.sampling_rate) |
| 61 | +inputs.to(model.device, dtype=model.dtype) |
| 62 | +outputs = model.generate(**inputs) |
| 63 | +print(processor.batch_decode(outputs)) |
| 64 | +``` |
| 65 | + |
| 66 | +</hfoption> |
| 67 | +</hfoptions> |
| 68 | + |
| 69 | +### Making The Model Go Brrr |
| 70 | + |
| 71 | +TODO |
| 72 | + |
| 73 | +### Training |
| 74 | + |
| 75 | +TODO |
| 76 | + |
| 77 | +## LasrTokenizer |
| 78 | + |
| 79 | +[[autodoc]] LasrTokenizer |
| 80 | + |
| 81 | +## LasrFeatureExtractor |
| 82 | + |
| 83 | +[[autodoc]] LasrFeatureExtractor |
| 84 | + - __call__ |
| 85 | + |
| 86 | +## LasrProcessor |
| 87 | + |
| 88 | +[[autodoc]] LasrProcessor |
| 89 | + - __call__ |
| 90 | + - batch_decode |
| 91 | + - decode |
| 92 | + |
| 93 | +## LasrEncoderConfig |
| 94 | + |
| 95 | +[[autodoc]] LasrEncoderConfig |
| 96 | + |
| 97 | +## LasrCTCConfig |
| 98 | + |
| 99 | +[[autodoc]] LasrCTCConfig |
| 100 | + |
| 101 | +## LasrEncoder |
| 102 | + |
| 103 | +[[autodoc]] LasrEncoder |
| 104 | + |
| 105 | +## LasrForCTC |
| 106 | + |
| 107 | +[[autodoc]] LasrForCTC |
| 108 | + |
0 commit comments