Views
No views yet
nguyenvulebinh/wav2vec2-large-vi-vlsp2020 model on the VIVOS: Vietnamese Speech Corpus for ASR.nguyenvulebinh/wav2vec2-large-vi-vlsp2020,transformers library:1from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
2import torch
3import soundfile as sf
4
5# Load processor and model
6processor = Wav2Vec2Processor.from_pretrained("your-username/your-model-repo")
7model = Wav2Vec2ForCTC.from_pretrained("your-username/your-model-repo")
8
9# Load audio file
10speech, rate = sf.read("path_to_your_audio.wav")
11
12# Preprocess
13input_values = processor(speech, sampling_rate=rate, return_tensors="pt", padding=True).input_values
14
15# Perform inference
16with torch.no_grad():
17 logits = model(input_values).logits
18
19# Decode prediction
20predicted_ids = torch.argmax(logits, dim=-1)
21transcription = processor.decode(predicted_ids[0])
22
23print("Transcription:", transcription)nguyenvulebinh/wav2vec2-large-vi-vlsp2020