Downloads · 30 days
7
7% of all-time downloads
Lam-Hung/xlsr-english-l2
xlsr-english-l2 is a machine learning model from Lam-Hung. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
import librosa import torch from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
Downloads · 30 days
7
7% of all-time downloads
All-time downloads
107
Public
Parameters
315M
1.3 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.3 GB · 100%
From the Hugging Face model README
import librosa
import torch
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
# Đường dẫn đến file wav của bạn
file_path = "19-198-0002.wav"
audio, sr = librosa.load(file_path, sr=16000)
print(f"Dạng dữ liệu: {type(audio)}")
print(f"Sample rate: {sr}")
print(f"Độ dài mảng: {audio.shape}")
# Tải model and processor đã được train
processor_l2 = Wav2Vec2Processor.from_pretrained("Lam-Hung/xlsr-english-l2", sampling_rate=16000)
model_l2 = Wav2Vec2ForCTC.from_pretrained("Lam-Hung/xlsr-english-l2")
# tokenize
input_values_l2 = processor_l2(audio, return_tensors="pt").input_values # type: ignore
with torch.no_grad():
logits = model_l2(input_values_l2).logits
# Lây argmax and decode
predicted_ids_l2 = torch.argmax(logits, dim=-1)
transcription_l2 = processor_l2.batch_decode(predicted_ids_l2)
for c in transcription_l2[0]:
print(c, end=' ')