Views
No views yet
pip install --upgrade pip
pip install --upgrade transformers sentencepiece datasets[audio]Text-to-Speech (TTS) pipeline. You can access the Arabic SPeechT5 model via the TTS pipeline in just a few lines of code!1from transformers import pipeline
2from datasets import load_dataset
3import soundfile as sf
4
5synthesiser = pipeline("text-to-speech", "MBZUAI/speecht5_tts_clartts_ar")
6
7embeddings_dataset = load_dataset("herwoww/arabic_xvector_embeddings", split="validation")
8speaker_embedding = torch.tensor(embeddings_dataset[105]["speaker_embeddings"]).unsqueeze(0)
9# You can replace this embedding with your own as well.
10
11speech = synthesiser("لأنه لا يرى أنه على السفه ثم من بعد ذلك حديث منتشر", forward_params={"speaker_embeddings": speaker_embedding})
12# ArTST is trained without diacritics.
13
14sf.write("speech.wav", speech["audio"], samplerate=speech["sampling_rate"])1from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, SpeechT5HifiGan
2from datasets import load_dataset
3import torch
4import soundfile as sf
5from datasets import load_dataset
6
7processor = SpeechT5Processor.from_pretrained("MBZUAI/speecht5_tts_clartts_ar")
8model = SpeechT5ForTextToSpeech.from_pretrained("MBZUAI/speecht5_tts_clartts_ar")
9vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")
10
11inputs = processor(text="لأنه لا يرى أنه على السفه ثم من بعد ذلك حديث منتشر", return_tensors="pt")
12
13# load xvector containing speaker's voice characteristics from a dataset
14embeddings_dataset = load_dataset("herwoww/arabic_xvector_embeddings", split="validation")
15speaker_embedding = torch.tensor(embeddings_dataset[105]["speaker_embeddings"]).unsqueeze(0)
16
17speech = model.generate_speech(inputs["input_ids"], speaker_embedding, vocoder=vocoder)
18
19sf.write("speech.wav", speech.numpy(), samplerate=16000)1@inproceedings{toyin-etal-2023-artst,
2 title = "{A}r{TST}: {A}rabic Text and Speech Transformer",
3 author = "Toyin, Hawau and
4 Djanibekov, Amirbek and
5 Kulkarni, Ajinkya and
6 Aldarmaki, Hanan",
7 editor = "Sawaf, Hassan and
8 El-Beltagy, Samhaa and
9 Zaghouani, Wajdi and
10 Magdy, Walid and
11 Abdelali, Ahmed and
12 Tomeh, Nadi and
13 Abu Farha, Ibrahim and
14 Habash, Nizar and
15 Khalifa, Salam and
16 Keleg, Amr and
17 Haddad, Hatem and
18 Zitouni, Imed and
19 Mrini, Khalil and
20 Almatham, Rawan",
21 booktitle = "Proceedings of ArabicNLP 2023",
22 month = dec,
23 year = "2023",
24 address = "Singapore (Hybrid)",
25 publisher = "Association for Computational Linguistics",
26 url = "https://aclanthology.org/2023.arabicnlp-1.5",
27 pages = "41--51"
28}
29@inproceedings{ao-etal-2022-speecht5,
30 title = {{S}peech{T}5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing},
31 author = {Ao, Junyi and Wang, Rui and Zhou, Long and Wang, Chengyi and Ren, Shuo and Wu, Yu and Liu, Shujie and Ko, Tom and Li, Qing and Zhang, Yu and Wei, Zhihua and Qian, Yao and Li, Jinyu and Wei, Furu},
32 booktitle = {Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
33 month = {May},
34 year = {2022},
35 pages={5723--5738},
36}