Views
No views yet
1import soundfile as sf
2from transformers import (
3 SpeechT5Config,
4 SpeechT5FeatureExtractor,
5 SpeechT5ForSpeechToText,
6 SpeechT5Processor,
7 SpeechT5Tokenizer,
8)
9
10
11device = "cuda" if torch.cuda.is_available() else "CPU"
12
13model_id="mbzuai/artst_asr_v3"
14
15tokenizer = SpeechT5Tokenizer.from_pretrained(model_id)
16processor = SpeechT5Processor.from_pretrained(model_id , tokenizer=tokenizer)
17model = SpeechT5ForSpeechToText.from_pretrained(model_id).to(device)
18
19audio, sr = sf.read("audio.wav")
20
21inputs = processor(audio=audio, sampling_rate=sr, return_tensors="pt")
22predicted_ids = model.generate(**inputs.to(device), max_length=150, num_beams=10)
23
24transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
25print(transcription[0])1import librosa
2from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor
3
4
5model_id="mbzuai/artst_asr_v3"
6processor = AutoProcessor.from_pretrained(model_id)
7model = AutoModelForSpeechSeq2Seq.from_pretrained(model_id).to(device)
8pipe = pipeline(
9 "automatic-speech-recognition",
10 model=model,
11 tokenizer=processor.tokenizer,
12 feature_extractor=processor.feature_extractor,
13 torch_dtype=torch_dtype,
14 device=device,
15)
16
17wav, sr = librosa.load("audio.wav", sr=16000)
18pipe(wav, generate_kwargs={'num_beams': 10, 'early_stopping': True})['text']@misc{djanibekov2024dialectalcoveragegeneralizationarabic,
title={Dialectal Coverage And Generalization in Arabic Speech Recognition},
author={Amirbek Djanibekov and Hawau Olamide Toyin and Raghad Alshalan and Abdullah Alitr and Hanan Aldarmaki},
year={2024},
eprint={2411.05872},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2411.05872},
}
@inproceedings{toyin-etal-2023-artst,
title = "{A}r{TST}: {A}rabic Text and Speech Transformer",
author = "Toyin, Hawau and
Djanibekov, Amirbek and
Kulkarni, Ajinkya and
Aldarmaki, Hanan",
booktitle = "Proceedings of ArabicNLP 2023",
month = dec,
year = "2023",
address = "Singapore (Hybrid)",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2023.arabicnlp-1.5",
doi = "10.18653/v1/2023.arabicnlp-1.5",
pages = "41--51",
}