herwoww commited on
Commit
c331458
1 Parent(s): 006edc3
Files changed (35) hide show
  1. app.py +26 -9
  2. artst/__pycache__/__init__.cpython-38.pyc +0 -0
  3. artst/criterions/__pycache__/__init__.cpython-38.pyc +0 -0
  4. artst/criterions/__pycache__/artst_criterion.cpython-38.pyc +0 -0
  5. artst/criterions/__pycache__/speech_pretrain_criterion.cpython-38.pyc +0 -0
  6. artst/criterions/__pycache__/speech_to_text_loss.cpython-38.pyc +0 -0
  7. artst/criterions/__pycache__/text_pretrain_criterion.cpython-38.pyc +0 -0
  8. artst/criterions/__pycache__/text_to_speech_loss.cpython-38.pyc +0 -0
  9. artst/data/__pycache__/__init__.cpython-38.pyc +0 -0
  10. artst/data/__pycache__/multitask_dataset.cpython-38.pyc +0 -0
  11. artst/data/__pycache__/speech_dataset.cpython-38.pyc +0 -0
  12. artst/data/__pycache__/speech_to_class_dataset.cpython-38.pyc +0 -0
  13. artst/data/__pycache__/speech_to_speech_dataset.cpython-38.pyc +0 -0
  14. artst/data/__pycache__/speech_to_text_dataset.cpython-38.pyc +0 -0
  15. artst/data/__pycache__/text_dataset.cpython-38.pyc +0 -0
  16. artst/data/__pycache__/text_to_speech_dataset.cpython-38.pyc +0 -0
  17. artst/models/__pycache__/__init__.cpython-38.pyc +0 -0
  18. artst/models/__pycache__/artst.cpython-38.pyc +0 -0
  19. artst/models/__pycache__/t5_transformer_lm.cpython-38.pyc +0 -0
  20. artst/models/modules/__pycache__/__init__.cpython-38.pyc +0 -0
  21. artst/models/modules/__pycache__/decoder.cpython-38.pyc +0 -0
  22. artst/models/modules/__pycache__/encoder.cpython-38.pyc +0 -0
  23. artst/models/modules/__pycache__/multihead_attention.cpython-38.pyc +0 -0
  24. artst/models/modules/__pycache__/speaker_decoder_postnet.cpython-38.pyc +0 -0
  25. artst/models/modules/__pycache__/speech_decoder_postnet.cpython-38.pyc +0 -0
  26. artst/models/modules/__pycache__/speech_decoder_prenet.cpython-38.pyc +0 -0
  27. artst/models/modules/__pycache__/speech_encoder_postnet.cpython-38.pyc +0 -0
  28. artst/models/modules/__pycache__/speech_encoder_prenet.cpython-38.pyc +0 -0
  29. artst/models/modules/__pycache__/text_decoder_postnet.cpython-38.pyc +0 -0
  30. artst/models/modules/__pycache__/text_decoder_prenet.cpython-38.pyc +0 -0
  31. artst/models/modules/__pycache__/text_encoder_prenet.cpython-38.pyc +0 -0
  32. artst/models/modules/__pycache__/transformer_layer.cpython-38.pyc +0 -0
  33. artst/tasks/__pycache__/__init__.cpython-38.pyc +0 -0
  34. artst/tasks/__pycache__/artst.cpython-38.pyc +0 -0
  35. requirements.txt → pre-requirements.txt +0 -0
app.py CHANGED
@@ -12,15 +12,12 @@ from fairseq.tasks.hubert_pretraining import LabelEncoder
12
  from fairseq.data.audio.speech_to_text_dataset import get_features_or_waveform
13
 
14
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
-
16
- WORK_DIR = os.getcwd()
17
  checkpoint = torch.load('ckpts/clartts_tts.pt')
18
  checkpoint['cfg']['task'].t5_task = 't2s'
19
- checkpoint['cfg']['task'].hubert_label_dir = "utils/"
20
  checkpoint['cfg']['task'].bpe_tokenizer = "utils/arabic.model"
21
  checkpoint['cfg']['task'].data = "utils/"
22
- checkpoint['cfg']['model'].mask_prob = 0.0
23
- checkpoint['cfg']['task'].mask_prob = 0.0
24
  task = ArTSTTask.setup_task(checkpoint['cfg']['task'])
25
 
26
  emb_path='embs/clartts.npy'
@@ -56,20 +53,40 @@ def inference(text, spkr=emb_path):
56
  )
57
  with torch.no_grad():
58
  gen_audio = vocoder(outs.to(device))
59
- return (16000,gen_audio.cpu().numpy())
 
60
 
61
  text_box = gr.Textbox(max_lines=2, label="Arabic Text", rtl=True)
62
  out = gr.Audio(label="Synthesized Audio", type="numpy")
63
  title="ArTST: Arabic Speech Synthesis"
64
  description="ArTST: Arabic text and speech transformer based on the T5 transformer. This space demonstarates the TTS checkpoint finetuned on \
65
- the CLARTTS dataset. The model is pre-trained on the MGB-2 dataset.Check the <a href='https://github.com/mbzuai-nlp/ArTST'> ArTST repo</a> for implementation code and \
66
- Read our <a href='https://arxiv.org/abs/2310.16621'>paper</a> for more details."
67
  examples=["لأن فراق المألوف في العادة ومجانبة ما صار متفقا عليه بالمواضعة",\
68
  "ومن لطيف حكمته أن جعل لكل عبادة حالتين",\
69
  "فمن لهم عدل الإنسان مع من فوقه"]
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  demo = gr.Interface(inference, \
72
- inputs=text_box, outputs=out, title=title, description=description, examples=examples)
73
 
74
  if __name__ == "__main__":
75
  demo.launch(share=True)
 
12
  from fairseq.data.audio.speech_to_text_dataset import get_features_or_waveform
13
 
14
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
 
15
  checkpoint = torch.load('ckpts/clartts_tts.pt')
16
  checkpoint['cfg']['task'].t5_task = 't2s'
 
17
  checkpoint['cfg']['task'].bpe_tokenizer = "utils/arabic.model"
18
  checkpoint['cfg']['task'].data = "utils/"
19
+ checkpoint['cfg']['model'].mask_prob = 0.5
20
+ checkpoint['cfg']['task'].mask_prob = 0.5
21
  task = ArTSTTask.setup_task(checkpoint['cfg']['task'])
22
 
23
  emb_path='embs/clartts.npy'
 
53
  )
54
  with torch.no_grad():
55
  gen_audio = vocoder(outs.to(device))
56
+ speech = (gen_audio.cpu().numpy() * 32767).astype(np.int16)
57
+ return (16000,speech)
58
 
59
  text_box = gr.Textbox(max_lines=2, label="Arabic Text", rtl=True)
60
  out = gr.Audio(label="Synthesized Audio", type="numpy")
61
  title="ArTST: Arabic Speech Synthesis"
62
  description="ArTST: Arabic text and speech transformer based on the T5 transformer. This space demonstarates the TTS checkpoint finetuned on \
63
+ the Classical Arabic Text-To-Speech (CLARTTS) dataset. The model is pre-trained on the MGB-2 dataset."
64
+
65
  examples=["لأن فراق المألوف في العادة ومجانبة ما صار متفقا عليه بالمواضعة",\
66
  "ومن لطيف حكمته أن جعل لكل عبادة حالتين",\
67
  "فمن لهم عدل الإنسان مع من فوقه"]
68
 
69
+ article = """
70
+ <div style='margin:20px auto;'>
71
+ <p>References: <a href="https://arxiv.org/abs/2310.16621">ArTST paper</a> |
72
+ <a href="https://github.com/mbzuai-nlp/ArTST">GitHub</a> |
73
+ <a href="https://huggingface.co/MBZUAI/ArTST">Weights and Tokenizer</a></p>
74
+ <pre>
75
+ @misc{toyin2023artst,
76
+ title={ArTST: Arabic Text and Speech Transformer},
77
+ author={Hawau Olamide Toyin and Amirbek Djanibekov and Ajinkya Kulkarni and Hanan Aldarmaki},
78
+ year={2023},
79
+ eprint={2310.16621},
80
+ archivePrefix={arXiv},
81
+ primaryClass={cs.CL}
82
+ }
83
+ </pre>
84
+ <p>Speaker embeddings were generated from <a href="http://www.festvox.org/cmu_arctic/">CMU ARCTIC</a>.</p>
85
+ </div>
86
+ """
87
+
88
  demo = gr.Interface(inference, \
89
+ inputs=text_box, outputs=out, title=title, description=description, examples=examples, article=article)
90
 
91
  if __name__ == "__main__":
92
  demo.launch(share=True)
artst/__pycache__/__init__.cpython-38.pyc CHANGED
Binary files a/artst/__pycache__/__init__.cpython-38.pyc and b/artst/__pycache__/__init__.cpython-38.pyc differ
 
artst/criterions/__pycache__/__init__.cpython-38.pyc CHANGED
Binary files a/artst/criterions/__pycache__/__init__.cpython-38.pyc and b/artst/criterions/__pycache__/__init__.cpython-38.pyc differ
 
artst/criterions/__pycache__/artst_criterion.cpython-38.pyc CHANGED
Binary files a/artst/criterions/__pycache__/artst_criterion.cpython-38.pyc and b/artst/criterions/__pycache__/artst_criterion.cpython-38.pyc differ
 
artst/criterions/__pycache__/speech_pretrain_criterion.cpython-38.pyc CHANGED
Binary files a/artst/criterions/__pycache__/speech_pretrain_criterion.cpython-38.pyc and b/artst/criterions/__pycache__/speech_pretrain_criterion.cpython-38.pyc differ
 
artst/criterions/__pycache__/speech_to_text_loss.cpython-38.pyc CHANGED
Binary files a/artst/criterions/__pycache__/speech_to_text_loss.cpython-38.pyc and b/artst/criterions/__pycache__/speech_to_text_loss.cpython-38.pyc differ
 
artst/criterions/__pycache__/text_pretrain_criterion.cpython-38.pyc CHANGED
Binary files a/artst/criterions/__pycache__/text_pretrain_criterion.cpython-38.pyc and b/artst/criterions/__pycache__/text_pretrain_criterion.cpython-38.pyc differ
 
artst/criterions/__pycache__/text_to_speech_loss.cpython-38.pyc CHANGED
Binary files a/artst/criterions/__pycache__/text_to_speech_loss.cpython-38.pyc and b/artst/criterions/__pycache__/text_to_speech_loss.cpython-38.pyc differ
 
artst/data/__pycache__/__init__.cpython-38.pyc CHANGED
Binary files a/artst/data/__pycache__/__init__.cpython-38.pyc and b/artst/data/__pycache__/__init__.cpython-38.pyc differ
 
artst/data/__pycache__/multitask_dataset.cpython-38.pyc CHANGED
Binary files a/artst/data/__pycache__/multitask_dataset.cpython-38.pyc and b/artst/data/__pycache__/multitask_dataset.cpython-38.pyc differ
 
artst/data/__pycache__/speech_dataset.cpython-38.pyc CHANGED
Binary files a/artst/data/__pycache__/speech_dataset.cpython-38.pyc and b/artst/data/__pycache__/speech_dataset.cpython-38.pyc differ
 
artst/data/__pycache__/speech_to_class_dataset.cpython-38.pyc CHANGED
Binary files a/artst/data/__pycache__/speech_to_class_dataset.cpython-38.pyc and b/artst/data/__pycache__/speech_to_class_dataset.cpython-38.pyc differ
 
artst/data/__pycache__/speech_to_speech_dataset.cpython-38.pyc CHANGED
Binary files a/artst/data/__pycache__/speech_to_speech_dataset.cpython-38.pyc and b/artst/data/__pycache__/speech_to_speech_dataset.cpython-38.pyc differ
 
artst/data/__pycache__/speech_to_text_dataset.cpython-38.pyc CHANGED
Binary files a/artst/data/__pycache__/speech_to_text_dataset.cpython-38.pyc and b/artst/data/__pycache__/speech_to_text_dataset.cpython-38.pyc differ
 
artst/data/__pycache__/text_dataset.cpython-38.pyc CHANGED
Binary files a/artst/data/__pycache__/text_dataset.cpython-38.pyc and b/artst/data/__pycache__/text_dataset.cpython-38.pyc differ
 
artst/data/__pycache__/text_to_speech_dataset.cpython-38.pyc CHANGED
Binary files a/artst/data/__pycache__/text_to_speech_dataset.cpython-38.pyc and b/artst/data/__pycache__/text_to_speech_dataset.cpython-38.pyc differ
 
artst/models/__pycache__/__init__.cpython-38.pyc CHANGED
Binary files a/artst/models/__pycache__/__init__.cpython-38.pyc and b/artst/models/__pycache__/__init__.cpython-38.pyc differ
 
artst/models/__pycache__/artst.cpython-38.pyc CHANGED
Binary files a/artst/models/__pycache__/artst.cpython-38.pyc and b/artst/models/__pycache__/artst.cpython-38.pyc differ
 
artst/models/__pycache__/t5_transformer_lm.cpython-38.pyc CHANGED
Binary files a/artst/models/__pycache__/t5_transformer_lm.cpython-38.pyc and b/artst/models/__pycache__/t5_transformer_lm.cpython-38.pyc differ
 
artst/models/modules/__pycache__/__init__.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/__init__.cpython-38.pyc and b/artst/models/modules/__pycache__/__init__.cpython-38.pyc differ
 
artst/models/modules/__pycache__/decoder.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/decoder.cpython-38.pyc and b/artst/models/modules/__pycache__/decoder.cpython-38.pyc differ
 
artst/models/modules/__pycache__/encoder.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/encoder.cpython-38.pyc and b/artst/models/modules/__pycache__/encoder.cpython-38.pyc differ
 
artst/models/modules/__pycache__/multihead_attention.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/multihead_attention.cpython-38.pyc and b/artst/models/modules/__pycache__/multihead_attention.cpython-38.pyc differ
 
artst/models/modules/__pycache__/speaker_decoder_postnet.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/speaker_decoder_postnet.cpython-38.pyc and b/artst/models/modules/__pycache__/speaker_decoder_postnet.cpython-38.pyc differ
 
artst/models/modules/__pycache__/speech_decoder_postnet.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/speech_decoder_postnet.cpython-38.pyc and b/artst/models/modules/__pycache__/speech_decoder_postnet.cpython-38.pyc differ
 
artst/models/modules/__pycache__/speech_decoder_prenet.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/speech_decoder_prenet.cpython-38.pyc and b/artst/models/modules/__pycache__/speech_decoder_prenet.cpython-38.pyc differ
 
artst/models/modules/__pycache__/speech_encoder_postnet.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/speech_encoder_postnet.cpython-38.pyc and b/artst/models/modules/__pycache__/speech_encoder_postnet.cpython-38.pyc differ
 
artst/models/modules/__pycache__/speech_encoder_prenet.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/speech_encoder_prenet.cpython-38.pyc and b/artst/models/modules/__pycache__/speech_encoder_prenet.cpython-38.pyc differ
 
artst/models/modules/__pycache__/text_decoder_postnet.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/text_decoder_postnet.cpython-38.pyc and b/artst/models/modules/__pycache__/text_decoder_postnet.cpython-38.pyc differ
 
artst/models/modules/__pycache__/text_decoder_prenet.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/text_decoder_prenet.cpython-38.pyc and b/artst/models/modules/__pycache__/text_decoder_prenet.cpython-38.pyc differ
 
artst/models/modules/__pycache__/text_encoder_prenet.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/text_encoder_prenet.cpython-38.pyc and b/artst/models/modules/__pycache__/text_encoder_prenet.cpython-38.pyc differ
 
artst/models/modules/__pycache__/transformer_layer.cpython-38.pyc CHANGED
Binary files a/artst/models/modules/__pycache__/transformer_layer.cpython-38.pyc and b/artst/models/modules/__pycache__/transformer_layer.cpython-38.pyc differ
 
artst/tasks/__pycache__/__init__.cpython-38.pyc CHANGED
Binary files a/artst/tasks/__pycache__/__init__.cpython-38.pyc and b/artst/tasks/__pycache__/__init__.cpython-38.pyc differ
 
artst/tasks/__pycache__/artst.cpython-38.pyc CHANGED
Binary files a/artst/tasks/__pycache__/artst.cpython-38.pyc and b/artst/tasks/__pycache__/artst.cpython-38.pyc differ
 
requirements.txt → pre-requirements.txt RENAMED
File without changes