Views
No views yet
1from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
2
3model = Wav2Vec2ForCTC.from_pretrained("Aditya3107/wav2vec2-large-xls-r-1b-ga-ie")
4processor = Wav2Vec2Processor.from_pretrained("Aditya3107/wav2vec2-large-xls-r-1b-ga-ie")
5
6# Reading taken audio clip
7import librosa, torch
8audio, rate = librosa.load("common-voice-irish/common_voice/cv-corpus-10.0-2022-07-04/ga-IE/clips/common_voice_ga-IE_1818627.mp3", sr = 16000)
9
10# Taking an input value
11input_values = processor(audio, sampling_rate=16_000, return_tensors = "pt", padding="longest").input_values
12# Storing logits (non-normalized prediction values)
13logits = model(input_values).logits
14# Storing predicted ids
15prediction = torch.argmax(logits, dim = -1)
16
17# Passing the prediction to the tokenizer decode to get the transcription
18transcription = processor.batch_decode(prediction)[0]
19print(transcription)Speaker sentences 0: #utts: 1
id: (common_voice_ga-IE_17401296.mp3)
Scores: (#C #S #D #I) 4 1 0 0
Attributes: Case_sensitve
REF: an bhfuil cóta bán óir
HYP: an bhfuil cóta bán air
Eval: S
id: (common_voice_ga-IE_17410244.mp3)
Scores: (#C #S #D #I) 3 1 0 2
Attributes: Case_sensitve
REF: *** ** an bud é sin
HYP: cad é an rud é sin
Eval: I I S
id: (common_voice_ga-IE_17410257.mp3)
Scores: (#C #S #D #I) 9 2 1 2
Attributes: Case_sensitve
REF: i gabhaim buíochas libh a chairde ******* ** támindéagtstruth le tuilleadh uaibh ar baá
HYP: * gabhaim buíochas libh a chairde táimid ag tsnúth le tuilleadh uaibh ar ball
Eval: D I I S S
id: (common_voice_ga-IE_17410401.mp3)
Scores: (#C #S #D #I) 6 1 0 0
Attributes: Case_sensitve
REF: níl ach tá peann ina phóca uige
HYP: níl ach tá peann ina phóca aige
Eval: S
id: (common_voice_ga-IE_17410403.mp3)
Scores: (#C #S #D #I) 5 1 0 1
Attributes: Case_sensitve
REF: agus *** cadé an dath atá air
HYP: agus cad é an dath atá air
Eval: I S
id: (common_voice_ga-IE_17410412.mp3)
Scores: (#C #S #D #I) 6 2 0 0
Attributes: Case_sensitve
REF: is lá é seo chun ceiliúradh a dhéan
HYP: is lá é seo chun céiliúradh a dhéanamh
Eval: S S
id: (common_voice_ga-IE_17444712.mp3)
Scores: (#C #S #D #I) 4 6 0 0
Attributes: Case_sensitve
REF: don chathaoileach mirín de brom don stiúrdhóirat liam ón maoladha
HYP: don chathaoirleach máirín de brún don stiúrthóir liam ó maolaodha
Eval: S S S S S S
id: (common_voice_ga-IE_17449454.mp3)
Scores: (#C #S #D #I) 4 0 0 0
Attributes: Case_sensitve
REF: ceacht a trí déag
HYP: ceacht a trí déag
Eval: @MISC {,
author = "Aditya Parikh",
title = "Finetuned XLS-R model for Irish (Ga-IE) language for Automatic Speech Recognition",
howpublished = "{\url{https://huggingface.co/Aditya3107/wav2vec2-large-xls-r-1b-ga-ie}}",
month = "aug",
year = "2022"
}