Automatic Speech Recognition
Transformers
PyTorch
Chinese
wav2vec2
audio
speech
xlsr-fine-tuning-week
Instructions to use gymeee/demo_code_switching with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gymeee/demo_code_switching with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="gymeee/demo_code_switching")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForCTC processor = AutoProcessor.from_pretrained("gymeee/demo_code_switching") model = AutoModelForCTC.from_pretrained("gymeee/demo_code_switching", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from gymeee/demo_code_switching: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/gymeee/demo_code_switching/resolve/main/README.md
- Command line
-
hf download hf://gymeee/demo_code_switching/README.md
-
curl -L -o README.md https://huggingface.co/gymeee/demo_code_switching/resolve/main/README.md
1.03 kB
metadata
license: apache-2.0
datasets:
- ASCEND
language:
- zh
metrics:
- cer
tags:
- audio
- automatic-speech-recognition
- speech
- xlsr-fine-tuning-week
inference
The model can be used directly (without a language model) as follows...
Using the HuggingSound library:
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
from datasets import load_dataset
import torch
import torchaudio
# load model and processor
processor = Wav2Vec2Processor.from_pretrained("gymeee/demo_code_switching")
model = Wav2Vec2ForCTC.from_pretrained("gymeee/demo_code_switching")
# load speech
speech_array, sampling_rate = torchaudio.load("speech.wav")
# tokenize
input_values = processor(speech_array[0], return_tensors="pt", padding="longest").input_values # Batch size 1
# retrieve logits
logits = model(input_values).logits
# take argmax and decode
predicted_ids = torch.argmax(logits, dim=-1)
transcription = processor.batch_decode(predicted_ids)
transcription