Automatic Speech Recognition
Transformers
Safetensors
wavlm
audio
speech
ctc
phone-recognition
arpabet
Instructions to use huper29/huper_recognizer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use huper29/huper_recognizer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="huper29/huper_recognizer")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForCTC processor = AutoProcessor.from_pretrained("huper29/huper_recognizer") model = AutoModelForCTC.from_pretrained("huper29/huper_recognizer", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -41,9 +41,19 @@ inputs = processor(waveform.squeeze().numpy(), sampling_rate=16000, return_tenso
|
|
| 41 |
with torch.no_grad():
|
| 42 |
logits = model(**inputs).logits
|
| 43 |
|
| 44 |
-
pred_ids = torch.argmax(logits, dim=-1)[0]
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
```
|
| 48 |
|
| 49 |
## Citation
|
|
|
|
| 41 |
with torch.no_grad():
|
| 42 |
logits = model(**inputs).logits
|
| 43 |
|
| 44 |
+
pred_ids = torch.argmax(logits, dim=-1)[0].tolist()
|
| 45 |
+
blank_id = processor.tokenizer.pad_token_id
|
| 46 |
+
|
| 47 |
+
phone_tokens = []
|
| 48 |
+
prev = None
|
| 49 |
+
for token_id in pred_ids:
|
| 50 |
+
if token_id != blank_id and token_id != prev:
|
| 51 |
+
token = model.config.id2label.get(token_id, processor.tokenizer.convert_ids_to_tokens(token_id))
|
| 52 |
+
if token not in {"<PAD>", "<UNK>", "<BOS>", "<EOS>", "|"}:
|
| 53 |
+
phone_tokens.append(token)
|
| 54 |
+
prev = token_id
|
| 55 |
+
|
| 56 |
+
print(" ".join(phone_tokens))
|
| 57 |
```
|
| 58 |
|
| 59 |
## Citation
|