aspmirlab commited on
Commit
95b880a
1 Parent(s): 66941bb

Upload folder using huggingface_hub

Browse files
.github/workflows/update_space.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Run Python script
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v2
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v2
18
+ with:
19
+ python-version: '3.9'
20
+
21
+ - name: Install Gradio
22
+ run: python -m pip install gradio
23
+
24
+ - name: Log in to Hugging Face
25
+ run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
26
+
27
+ - name: Deploy to Spaces
28
+ run: gradio deploy
.gradio/certificate.pem ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
3
+ TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
4
+ cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
5
+ WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
6
+ ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
7
+ MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
8
+ h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
9
+ 0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
10
+ A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
11
+ T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
12
+ B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
13
+ B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
14
+ KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn
15
+ OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn
16
+ jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw
17
+ qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI
18
+ rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
19
+ HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq
20
+ hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
21
+ ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ
22
+ 3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK
23
+ NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
24
+ ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
25
+ TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
26
+ jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
27
+ oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
28
+ 4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
29
+ mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
30
+ emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
31
+ -----END CERTIFICATE-----
.ipynb_checkpoints/ASPMIR-YorTTS-checkpoint.ipynb ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 55,
6
+ "id": "23e98a8a-7128-4f35-ba1c-ff514ed462e0",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "#Install Dependencies\n",
11
+ "#!pip3 install torch torchvision torchaudio\n",
12
+ "#!pip install transformers ipywidgets gradio --upgrade\n",
13
+ "#!pip install --upgrade gradio\n",
14
+ "#!pip install nltk\n",
15
+ "#!pip install jiwer\n",
16
+ "#!pip install sentencepiece\n",
17
+ "#!pip install sacremoses\n",
18
+ "#!pip install soundfile"
19
+ ]
20
+ },
21
+ {
22
+ "cell_type": "code",
23
+ "execution_count": 56,
24
+ "id": "29275fa9-1b88-4e37-a278-7118bfca860a",
25
+ "metadata": {},
26
+ "outputs": [],
27
+ "source": [
28
+ "\n",
29
+ "##translation_pipeline = pipeline('translation_en_to_fr')\n",
30
+ "##Evaluation Metric = BLEU score\n",
31
+ "##Exp1\n",
32
+ "#model_name = \"Davlan/byt5-base-eng-yor-mt\"\n",
33
+ "##Exp2\n",
34
+ "#model_name = \"Davlan/m2m100_418M-eng-yor-mt\" \n",
35
+ "##Exp3\n",
36
+ "#model_name = \"Davlan/mbart50-large-eng-yor-mt\"\n",
37
+ "##Exp4\n",
38
+ "#model_name = \"Davlan/mt5_base_eng_yor_mt\"\n",
39
+ "##Exp5\n",
40
+ "#model_name = \"omoekan/opus-tatoeba-eng-yor\"\n",
41
+ "##Exp6\n",
42
+ "#model_name = \"masakhane/afrimt5_en_yor_news\"\n",
43
+ "##Exp7\n",
44
+ "#model_name = \"masakhane/afrimbart_en_yor_news\"\n",
45
+ "##Exp8\n",
46
+ "#model_name = \"masakhane/afribyt5_en_yor_news\"\n",
47
+ "##Exp9\n",
48
+ "#model_name = \"masakhane/byt5_en_yor_news\"\n",
49
+ "##Exp10\n",
50
+ "#model_name = \"masakhane/mt5_en_yor_news\"\n",
51
+ "#translation_pipeline = pipeline('translation_en_to_yo', model = model_name, max_length=50)"
52
+ ]
53
+ },
54
+ {
55
+ "cell_type": "code",
56
+ "execution_count": 57,
57
+ "id": "1ea4a2eb-6cbf-497a-a080-2db3dd64be36",
58
+ "metadata": {},
59
+ "outputs": [],
60
+ "source": [
61
+ "#results = translation_pipeline('My Name is Ayo, I love books')\n",
62
+ "#results[0]['translation_text']"
63
+ ]
64
+ },
65
+ {
66
+ "cell_type": "code",
67
+ "execution_count": 58,
68
+ "id": "f92487b5-158a-47ef-ab12-a361ea8d0a48",
69
+ "metadata": {},
70
+ "outputs": [],
71
+ "source": [
72
+ "#results = translation_pipeline('The wages of sin is death')\n",
73
+ "#results[0]['translation_text']"
74
+ ]
75
+ },
76
+ {
77
+ "cell_type": "code",
78
+ "execution_count": 59,
79
+ "id": "69d64db9-b083-46ae-80ce-9616ba99183d",
80
+ "metadata": {},
81
+ "outputs": [],
82
+ "source": [
83
+ "from transformers import pipeline\n",
84
+ "import nltk\n",
85
+ "import jiwer\n",
86
+ "from nltk.translate.bleu_score import corpus_bleu\n",
87
+ "from transformers import VitsModel, AutoTokenizer\n",
88
+ "import torch\n",
89
+ "import soundfile as sf\n",
90
+ "\n",
91
+ "\n",
92
+ "WerScore = 0\n",
93
+ "bleuScore = 0\n",
94
+ "def translate_transformers(modelName, sourceLangText):\n",
95
+ " #results = translation_pipeline(input_text)\n",
96
+ " translation_pipeline = pipeline('translation_en_to_yo', model = modelName, max_length=500)\n",
97
+ " translated_text = translation_pipeline(sourceLangText) #translator(text)[0][\"translation_text\"]\n",
98
+ " translated_text_target = translated_text[0]['translation_text']\n",
99
+ " hypothesis_translations = \"My name is Joy, I love reading\"\n",
100
+ " \n",
101
+ " #TTS for the translated_text_target\n",
102
+ " #TTS Exp1\n",
103
+ " ttsModel = VitsModel.from_pretrained(\"facebook/mms-tts-yor\")\n",
104
+ " tokenizer = AutoTokenizer.from_pretrained(\"facebook/mms-tts-yor\")\n",
105
+ " ttsInputs = tokenizer(translated_text_target, return_tensors=\"pt\")\n",
106
+ " \n",
107
+ " with torch.no_grad():\n",
108
+ " ttsOutput = ttsModel(**ttsInputs).waveform\n",
109
+ " #onvert the tensor to a numpy array\n",
110
+ " ttsWaveform = ttsOutput.numpy()[0] \n",
111
+ " #Save the waveform to an audio file\n",
112
+ " #sf.write('output.wav', waveform, 22050)\n",
113
+ " sf.write('ttsOutput.wav', ttsWaveform, 16000)\n",
114
+ " \n",
115
+ " #Calculate WerScore\n",
116
+ " WerScore = jiwer.wer(translated_text_target, hypothesis_translations)\n",
117
+ " #bleuScore = corpus_bleu(translated_text_target,hypothesis_translations)\n",
118
+ " \n",
119
+ " return translated_text_target,WerScore,'ttsOutput.wav'"
120
+ ]
121
+ },
122
+ {
123
+ "cell_type": "code",
124
+ "execution_count": 60,
125
+ "id": "5d9ed5a2-0d28-4078-923d-c8c27196292a",
126
+ "metadata": {},
127
+ "outputs": [],
128
+ "source": [
129
+ "#text1 = \"Oruko mi ni Ayo, mo feran iwe kika gan\"\n",
130
+ "#text2 = \"Agbaninímọ̀ràn kan lórí ọ̀ràn radiation and Clinical Oncologist, tórúkọ rẹ̀ ń jẹ́ Temitope Olatunji-Agunbiade ti kìlọ̀ fáwọn obìnrin pé kí wọ́n má ṣe lo oògùn máàjóyúndúró tàbí kí wọ́n lo oògùn máàjóyúndúró, ó sọ pé ìwádìí ti fi hàn pé lílò tí wọ́n ń lò ó ń mú kí ewu àrùn jẹjẹrẹ ọmú pọ̀ sí i.\"\n",
131
+ "\n",
132
+ "#with torch.no_grad():\n",
133
+ " #output = ttsModel(**inputs).waveform"
134
+ ]
135
+ },
136
+ {
137
+ "cell_type": "code",
138
+ "execution_count": 61,
139
+ "id": "54138308-b423-4e7c-9469-2002bfeb7918",
140
+ "metadata": {},
141
+ "outputs": [],
142
+ "source": [
143
+ "#from IPython.display import Audio\n",
144
+ "#Audio(output, rate=ttsModel.config.sampling_rate)"
145
+ ]
146
+ },
147
+ {
148
+ "cell_type": "code",
149
+ "execution_count": 62,
150
+ "id": "bbf259d6-922d-4f5c-9af1-cbd57158a814",
151
+ "metadata": {},
152
+ "outputs": [
153
+ {
154
+ "name": "stdout",
155
+ "output_type": "stream",
156
+ "text": [
157
+ "Running on local URL: http://127.0.0.1:7879\n",
158
+ "Running on public URL: https://ccee705195aed67b23.gradio.live\n",
159
+ "\n",
160
+ "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
161
+ ]
162
+ },
163
+ {
164
+ "data": {
165
+ "text/html": [
166
+ "<div><iframe src=\"https://ccee705195aed67b23.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
167
+ ],
168
+ "text/plain": [
169
+ "<IPython.core.display.HTML object>"
170
+ ]
171
+ },
172
+ "metadata": {},
173
+ "output_type": "display_data"
174
+ },
175
+ {
176
+ "data": {
177
+ "text/plain": []
178
+ },
179
+ "execution_count": 62,
180
+ "metadata": {},
181
+ "output_type": "execute_result"
182
+ }
183
+ ],
184
+ "source": [
185
+ "#Gradio Function and Interface\n",
186
+ "import gradio as gr\n",
187
+ "from IPython.display import Audio\n",
188
+ "interface = gr.Interface(\n",
189
+ " fn=translate_transformers,\n",
190
+ " inputs=[\n",
191
+ " gr.Dropdown([\"Davlan/byt5-base-eng-yor-mt\", #Exp1\n",
192
+ " \"Davlan/m2m100_418M-eng-yor-mt\", #Exp2\n",
193
+ " \"Davlan/mbart50-large-eng-yor-mt\", #Exp3\n",
194
+ " \"Davlan/mt5_base_eng_yor_mt\", #Exp4\n",
195
+ " \"omoekan/opus-tatoeba-eng-yor\", #Exp5\n",
196
+ " \"masakhane/afrimt5_en_yor_news\", #Exp6\n",
197
+ " \"masakhane/afrimbart_en_yor_news\", #Exp7\n",
198
+ " \"masakhane/afribyt5_en_yor_news\", #Exp8\n",
199
+ " \"masakhane/byt5_en_yor_news\", #Exp9\n",
200
+ " \"masakhane/mt5_en_yor_news\", #Exp10\n",
201
+ " \"masakhane/mbart50_en_yor_news\", #Exp11\n",
202
+ " \"masakhane/m2m100_418M_en_yor_news\", #Exp12\n",
203
+ " \"masakhane/m2m100_418M_en_yor_rel_news\", #Exp13\n",
204
+ " \"masakhane/m2m100_418M_en_yor_rel_news_ft\", #Exp14\n",
205
+ " \"masakhane/m2m100_418M_en_yor_rel\", #Exp15\n",
206
+ " #\"facebook/nllb-200-distilled-600M\", #Exp16\n",
207
+ " #\"facebook/nllb-200-3.3B\", #Exp17\n",
208
+ " #\"facebook/nllb-200-1.3B\", #Exp18\n",
209
+ " #\"facebook/nllb-200-distilled-1.3B\", #Exp19\n",
210
+ " #\"keithhon/nllb-200-3.3B\" #Exp20\n",
211
+ " #\"CohereForAI/aya-101\" #Exp16\n",
212
+ " ], \n",
213
+ " label=\"Select Finetuned Eng2Yor Translation Model\"),\n",
214
+ " gr.Textbox(lines=2, placeholder=\"Enter English Text Here...\", label=\"English Text\") \n",
215
+ " ],\n",
216
+ " #outputs = \"text\",\n",
217
+ " #outputs=outputs=[\"text\", \"text\"],#\"text\"\n",
218
+ " #outputs= gr.Textbox(value=\"text\", label=\"Translated Text\"),\n",
219
+ " outputs=[\n",
220
+ " gr.Textbox(value=\"text\", label=\"Translated Yoruba Text\"),\n",
221
+ " #gr.Textbox(value=\"text\", label=translated_text_actual),\n",
222
+ " gr.Textbox(value=\"number\", label=\"WER(Word Error Rate) Score - The Lower the Better\"),\n",
223
+ " #gr.Textbox(value=\"number\", label=\"Bleu Score\")\n",
224
+ " gr.Audio(type=\"filepath\", label=\"Click to Generate Yoruba Text2Speech\")\n",
225
+ " ],\n",
226
+ " title=\"ASPMIR NEURAL MACHINE TRANSLATION(NMT) TESTBED FOR LOW RESOURCED AFRICAN LANGUAGES\",\n",
227
+ " description=\"{This Tool Allows Developers and Researchers to Carry Out Experiments on Low Resourced African Languages with State-of-the-Art NMT Finetuned Models.}\"\n",
228
+ ")\n",
229
+ "\n",
230
+ "interface.launch(share=True)"
231
+ ]
232
+ },
233
+ {
234
+ "cell_type": "code",
235
+ "execution_count": null,
236
+ "id": "c3baee0f-fd85-4209-9d54-14451abd372a",
237
+ "metadata": {},
238
+ "outputs": [],
239
+ "source": []
240
+ }
241
+ ],
242
+ "metadata": {
243
+ "kernelspec": {
244
+ "display_name": "Python 3 (ipykernel)",
245
+ "language": "python",
246
+ "name": "python3"
247
+ },
248
+ "language_info": {
249
+ "codemirror_mode": {
250
+ "name": "ipython",
251
+ "version": 3
252
+ },
253
+ "file_extension": ".py",
254
+ "mimetype": "text/x-python",
255
+ "name": "python",
256
+ "nbconvert_exporter": "python",
257
+ "pygments_lexer": "ipython3",
258
+ "version": "3.10.10"
259
+ }
260
+ },
261
+ "nbformat": 4,
262
+ "nbformat_minor": 5
263
+ }
.ipynb_checkpoints/requirements-checkpoint.txt ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==1.4.0
2
+ accelerate==1.2.0
3
+ aiofiles==23.2.1
4
+ aiohttp==3.9.0
5
+ aiohttp-cors==0.7.0
6
+ aiosignal==1.3.1
7
+ alembic==1.12.1
8
+ altair==5.2.0
9
+ annotated-types==0.6.0
10
+ anyio==4.0.0
11
+ argon2-cffi==23.1.0
12
+ argon2-cffi-bindings==21.2.0
13
+ array-record==0.5.0
14
+ arrow==1.3.0
15
+ asttokens==2.4.1
16
+ astunparse==1.6.3
17
+ async-generator==1.10
18
+ async-lru==2.0.4
19
+ async-timeout==4.0.3
20
+ attrs==23.1.0
21
+ audioread==3.0.1
22
+ Babel==2.13.1
23
+ beautifulsoup4==4.12.2
24
+ bleach==6.1.0
25
+ blessed==1.20.0
26
+ boltons @ file:///home/conda/feedstock_root/build_artifacts/boltons_1677499911949/work
27
+ brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1666764671472/work
28
+ cachetools==5.3.2
29
+ certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1707022139797/work/certifi
30
+ certipy==0.1.3
31
+ cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1671179353105/work
32
+ charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1678108872112/work
33
+ click==8.1.7
34
+ colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1666700638685/work
35
+ colorful==0.5.5
36
+ comm==0.2.0
37
+ conda==23.3.1
38
+ conda-package-handling @ file:///home/conda/feedstock_root/build_artifacts/conda-package-handling_1669907009957/work
39
+ conda_package_streaming @ file:///home/conda/feedstock_root/build_artifacts/conda-package-streaming_1669733752472/work
40
+ contourpy==1.2.0
41
+ cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography-split_1679811212387/work
42
+ cycler==0.12.1
43
+ debugpy==1.8.0
44
+ decorator==5.1.1
45
+ defusedxml==0.7.1
46
+ distlib==0.3.7
47
+ dm-tree==0.1.8
48
+ et-xmlfile==1.1.0
49
+ etils==1.6.0
50
+ exceptiongroup==1.1.3
51
+ executing==2.0.1
52
+ fastapi==0.115.6
53
+ fastjsonschema==2.19.0
54
+ ffmpy==0.3.1
55
+ filelock @ file:///home/conda/feedstock_root/build_artifacts/filelock_1698714947081/work
56
+ flatbuffers==23.5.26
57
+ fonttools==4.44.3
58
+ fqdn==1.5.1
59
+ frozenlist==1.4.0
60
+ fsspec==2024.2.0
61
+ gast==0.5.4
62
+ GDAL @ file:///home/conda/feedstock_root/build_artifacts/gdal-split_1680712150998/work/build/swig/python
63
+ gmpy2 @ file:///home/conda/feedstock_root/build_artifacts/gmpy2_1666808654411/work
64
+ google-api-core==2.14.0
65
+ google-auth==2.23.4
66
+ google-auth-oauthlib==1.1.0
67
+ google-pasta==0.2.0
68
+ googleapis-common-protos==1.61.0
69
+ gpustat==1.1.1
70
+ gradio==5.8.0
71
+ gradio_client==1.5.1
72
+ greenlet==3.0.1
73
+ grpcio==1.59.3
74
+ gTTS==2.5.1
75
+ h11==0.14.0
76
+ h5py==3.10.0
77
+ httpcore==1.0.2
78
+ httpx==0.26.0
79
+ huggingface-hub==0.26.3
80
+ idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1663625384323/work
81
+ importlib-resources==6.1.1
82
+ ipykernel==6.26.0
83
+ ipython==8.17.2
84
+ ipywidgets==8.1.2
85
+ isoduration==20.11.0
86
+ jedi==0.19.1
87
+ Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1654302431367/work
88
+ jiwer==3.0.3
89
+ joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1691577114857/work
90
+ json5==0.9.14
91
+ jsonpatch @ file:///home/conda/feedstock_root/build_artifacts/jsonpatch_1695536281965/work
92
+ jsonpointer @ file:///home/conda/feedstock_root/build_artifacts/jsonpointer_1695397238043/work
93
+ jsonschema==4.20.0
94
+ jsonschema-specifications==2023.11.1
95
+ jupyter-events==0.9.0
96
+ jupyter-lsp==2.2.0
97
+ jupyter-resource-usage==1.0.1
98
+ jupyter-telemetry==0.1.0
99
+ jupyter_client==8.6.0
100
+ jupyter_core==5.5.0
101
+ jupyter_server==2.10.1
102
+ jupyter_server_terminals==0.4.4
103
+ jupyterhub==4.0.2
104
+ jupyterlab==4.0.9
105
+ jupyterlab-pygments==0.2.2
106
+ jupyterlab_server==2.25.2
107
+ jupyterlab_widgets==3.0.10
108
+ keras==2.15.0
109
+ kiwisolver==1.4.5
110
+ lazy_loader==0.4
111
+ libclang==16.0.6
112
+ libmambapy @ file:///home/conda/feedstock_root/build_artifacts/mamba-split_1680002410624/work/libmambapy
113
+ librosa==0.10.2.post1
114
+ llvmlite==0.43.0
115
+ lxml==5.1.0
116
+ Mako==1.3.0
117
+ mamba @ file:///home/conda/feedstock_root/build_artifacts/mamba-split_1680002410624/work/mamba
118
+ Markdown==3.5.1
119
+ markdown-it-py==3.0.0
120
+ MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1695367434228/work
121
+ matlab-kernel==0.17.1
122
+ matplotlib==3.8.2
123
+ matplotlib-inline==0.1.6
124
+ mdurl==0.1.2
125
+ metakernel==0.30.2
126
+ mistune==3.0.2
127
+ ml-dtypes==0.2.0
128
+ mpmath @ file:///home/conda/feedstock_root/build_artifacts/mpmath_1678228039184/work
129
+ msgpack==1.0.7
130
+ multidict==6.0.4
131
+ nbclient==0.9.0
132
+ nbconvert==7.11.0
133
+ nbformat==5.9.2
134
+ nbgitpuller==1.2.0
135
+ nest-asyncio==1.5.8
136
+ networkx @ file:///home/conda/feedstock_root/build_artifacts/networkx_1698504735452/work
137
+ nltk==3.8.1
138
+ notebook==7.0.6
139
+ notebook_shim==0.2.3
140
+ numba==0.60.0
141
+ numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1695290862901/work/dist/numpy-1.26.0-cp310-cp310-linux_x86_64.whl#sha256=44509c98ccedaff13cf312f80a8e392a35d5f649bdf63f1b7e705fdfdc621c6d
142
+ nvidia-cublas-cu12==12.1.3.1
143
+ nvidia-cuda-cupti-cu12==12.1.105
144
+ nvidia-cuda-nvcc-cu12==12.2.140
145
+ nvidia-cuda-nvrtc-cu12==12.1.105
146
+ nvidia-cuda-runtime-cu12==12.1.105
147
+ nvidia-cudnn-cu12==8.9.2.26
148
+ nvidia-cufft-cu12==11.0.2.54
149
+ nvidia-curand-cu12==10.3.2.106
150
+ nvidia-cusolver-cu12==11.4.5.107
151
+ nvidia-cusparse-cu12==12.1.0.106
152
+ nvidia-ml-py==12.535.133
153
+ nvidia-nccl-cu12==2.20.5
154
+ nvidia-nvjitlink-cu12==12.2.140
155
+ nvidia-nvtx-cu12==12.1.105
156
+ oauthlib==3.2.2
157
+ opencensus==0.11.3
158
+ opencensus-context==0.1.3
159
+ opencv-python==4.8.1.78
160
+ openpyxl==3.1.3
161
+ opt-einsum==3.3.0
162
+ orjson==3.9.13
163
+ overrides==7.4.0
164
+ packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1696202382185/work
165
+ pamela==1.1.0
166
+ pandas==2.1.3
167
+ pandocfilters==1.5.0
168
+ parso==0.8.3
169
+ pexpect==4.8.0
170
+ Pillow==10.1.0
171
+ platformdirs==3.11.0
172
+ pluggy @ file:///home/conda/feedstock_root/build_artifacts/pluggy_1667232663820/work
173
+ pooch==1.8.2
174
+ portalocker==2.8.2
175
+ prometheus-client==0.18.0
176
+ promise==2.3
177
+ prompt-toolkit==3.0.41
178
+ protobuf==3.20.3
179
+ psutil==5.9.6
180
+ ptyprocess==0.7.0
181
+ pure-eval==0.2.2
182
+ py-spy==0.3.14
183
+ pyasn1==0.5.0
184
+ pyasn1-modules==0.3.0
185
+ pycosat @ file:///home/conda/feedstock_root/build_artifacts/pycosat_1666836542287/work
186
+ pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work
187
+ pydantic==2.6.1
188
+ pydantic_core==2.16.2
189
+ pydub==0.25.1
190
+ Pygments==2.17.0
191
+ pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1680037383858/work
192
+ pyparsing==3.1.1
193
+ PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1661604839144/work
194
+ python-dateutil==2.8.2
195
+ python-json-logger==2.0.7
196
+ python-multipart==0.0.19
197
+ pytz==2023.3.post1
198
+ PyYAML==6.0.1
199
+ pyzmq==25.1.1
200
+ rapidfuzz==3.6.1
201
+ ray==2.8.0
202
+ referencing==0.31.0
203
+ regex==2023.12.25
204
+ requests==2.31.0
205
+ requests-oauthlib==1.3.1
206
+ rfc3339-validator==0.1.4
207
+ rfc3986-validator==0.1.1
208
+ rich==13.7.0
209
+ rpds-py==0.13.0
210
+ rsa==4.9
211
+ ruamel.yaml @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml_1678272977710/work
212
+ ruamel.yaml.clib @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml.clib_1670412719074/work
213
+ ruff==0.2.2
214
+ sacrebleu==2.4.0
215
+ sacremoses==0.1.1
216
+ safehttpx==0.1.6
217
+ safetensors==0.4.5
218
+ scapy==2.5.0
219
+ scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1698224870717/work
220
+ scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy-split_1696467628975/work/dist/scipy-1.11.3-cp310-cp310-linux_x86_64.whl#sha256=1a1f6f0b1d49eca3673dad934971d667767456b5f7effcaf9f07cdd3ba377c95
221
+ seaborn==0.13.2
222
+ semantic-version==2.10.0
223
+ Send2Trash==1.8.2
224
+ sentencepiece==0.2.0
225
+ shellingham==1.5.4
226
+ six==1.16.0
227
+ smart-open==6.4.0
228
+ sniffio==1.3.0
229
+ soundfile==0.12.1
230
+ soupsieve==2.5
231
+ soxr==0.5.0.post1
232
+ spicy==0.16.0
233
+ split-folders==0.5.1
234
+ SQLAlchemy==2.0.23
235
+ stack-data==0.6.3
236
+ starlette==0.41.3
237
+ sympy @ file:///home/conda/feedstock_root/build_artifacts/sympy_1684180540116/work
238
+ tabulate==0.9.0
239
+ tensorboard==2.15.1
240
+ tensorboard-data-server==0.7.2
241
+ tensorflow==2.15.0.post1
242
+ tensorflow-estimator==2.15.0
243
+ tensorflow-io-gcs-filesystem==0.34.0
244
+ tensorflow-metadata==1.14.0
245
+ termcolor==2.4.0
246
+ terminado==0.18.0
247
+ tfds-nightly==4.9.3.dev202312070044
248
+ there==0.0.12
249
+ threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1689261241048/work
250
+ tinycss2==1.2.1
251
+ tokenizers==0.21.0
252
+ toml==0.10.2
253
+ tomli==2.0.1
254
+ tomlkit==0.12.0
255
+ toolz @ file:///home/conda/feedstock_root/build_artifacts/toolz_1657485559105/work
256
+ torch==2.3.1
257
+ torchaudio==2.1.1+cu118
258
+ torchvision==0.16.1+cu118
259
+ tornado==6.3.3
260
+ tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1677948868469/work
261
+ traitlets==5.13.0
262
+ transformers==4.47.0
263
+ triton==2.3.1
264
+ typer==0.12.3
265
+ types-python-dateutil==2.8.19.14
266
+ typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1695040754690/work
267
+ tzdata==2023.3
268
+ uri-template==1.3.0
269
+ urllib3==2.2.1
270
+ uvicorn==0.27.0.post1
271
+ virtualenv==20.21.0
272
+ wcwidth==0.2.10
273
+ webcolors==1.13
274
+ webencodings==0.5.1
275
+ websocket-client==1.6.4
276
+ websockets==11.0.3
277
+ Werkzeug==3.0.1
278
+ widgetsnbextension==4.0.10
279
+ wrapt==1.14.1
280
+ wurlitzer==3.1.1
281
+ yarl==1.9.2
282
+ zipp==3.17.0
283
+ zstandard==0.19.0
ASPMIR-YorTTS.ipynb ADDED
@@ -0,0 +1,402 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "23e98a8a-7128-4f35-ba1c-ff514ed462e0",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "#Install All the Required Dependencies\n",
11
+ "#!pip3 install torch torchvision torchaudio\n",
12
+ "#!pip install transformers ipywidgets gradio --upgrade\n",
13
+ "#!pip install --upgrade transformers accelerate\n",
14
+ "#!pip install --upgrade gradio\n",
15
+ "#!pip install nltk\n",
16
+ "#!pip install jiwer\n",
17
+ "#!pip install sentencepiece\n",
18
+ "#!pip install sacremoses\n",
19
+ "#!pip install soundfile\n",
20
+ "#!pip install librosa numpy jiwer nltk\n",
21
+ "#!pip install --upgrade pip \n",
22
+ "#!pip install huggingface_hub"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": 2,
28
+ "id": "0d2a7d3a-8c2c-4134-a79f-a3b7b1747874",
29
+ "metadata": {},
30
+ "outputs": [
31
+ {
32
+ "name": "stderr",
33
+ "output_type": "stream",
34
+ "text": [
35
+ "2024-12-20 20:13:51.723870: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n",
36
+ "2024-12-20 20:13:51.767697: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
37
+ "2024-12-20 20:13:51.767728: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
38
+ "2024-12-20 20:13:51.768839: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n",
39
+ "2024-12-20 20:13:51.775965: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n",
40
+ "To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
41
+ "2024-12-20 20:13:52.795860: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n"
42
+ ]
43
+ }
44
+ ],
45
+ "source": [
46
+ "#Import Required Libraries\n",
47
+ "from transformers import pipeline\n",
48
+ "from jiwer import wer\n",
49
+ "from transformers import VitsModel, AutoTokenizer, set_seed\n",
50
+ "import torch\n",
51
+ "import soundfile as sf\n",
52
+ "import librosa\n",
53
+ "from scipy.spatial.distance import euclidean\n",
54
+ "import numpy as np\n",
55
+ "import string\n",
56
+ "import os\n",
57
+ "from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction\n",
58
+ "from nltk.translate.meteor_score import meteor_score\n",
59
+ "import string\n",
60
+ "import numpy as np\n",
61
+ "import librosa\n",
62
+ "from scipy.spatial.distance import euclidean\n",
63
+ "import string\n"
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "code",
68
+ "execution_count": 3,
69
+ "id": "e2bafb31-ecf6-44e4-b25a-24abfa75bed1",
70
+ "metadata": {},
71
+ "outputs": [
72
+ {
73
+ "name": "stdout",
74
+ "output_type": "stream",
75
+ "text": [
76
+ "['/home/jupyter-prof-adetiba/nltk_data', '/opt/tljh/user/nltk_data', '/opt/tljh/user/share/nltk_data', '/opt/tljh/user/lib/nltk_data', '/usr/share/nltk_data', '/usr/local/share/nltk_data', '/usr/lib/nltk_data', '/usr/local/lib/nltk_data']\n"
77
+ ]
78
+ },
79
+ {
80
+ "name": "stderr",
81
+ "output_type": "stream",
82
+ "text": [
83
+ "[nltk_data] Downloading package wordnet to /home/jupyter-prof-\n",
84
+ "[nltk_data] adetiba/nltk_data...\n",
85
+ "[nltk_data] Package wordnet is already up-to-date!\n",
86
+ "[nltk_data] Downloading package omw-1.4 to /home/jupyter-prof-\n",
87
+ "[nltk_data] adetiba/nltk_data...\n",
88
+ "[nltk_data] Package omw-1.4 is already up-to-date!\n"
89
+ ]
90
+ }
91
+ ],
92
+ "source": [
93
+ "import nltk\n",
94
+ "nltk.download('wordnet')\n",
95
+ "nltk.download('omw-1.4') # Optional if using WordNet's multilingual features\n",
96
+ "import nltk\n",
97
+ "print(nltk.data.path)\n",
98
+ "import nltk\n",
99
+ "nltk.data.path.append('./nltk_data')"
100
+ ]
101
+ },
102
+ {
103
+ "cell_type": "code",
104
+ "execution_count": 4,
105
+ "id": "10ceb8b4-fe4e-4a97-ac34-dce6a890455a",
106
+ "metadata": {},
107
+ "outputs": [],
108
+ "source": [
109
+ "#Define all Utility Functions\n",
110
+ "# Function to compute BLEU score\n",
111
+ "def compute_bleu(reference_text, predicted_text):\n",
112
+ " \"\"\"\n",
113
+ " Computes the BLEU score for a single translation.\n",
114
+ " :param reference_text: The ground truth text (in Yoruba).\n",
115
+ " :param predicted_text: The machine-generated translation text (in Yoruba).\n",
116
+ " :return: BLEU score (float).\n",
117
+ " \"\"\"\n",
118
+ " print(\"The Reference Text = \", reference_text)\n",
119
+ " print(\"The Predicted Text = \",predicted_text)\n",
120
+ " # Tokenize the reference and predicted texts\n",
121
+ " reference_tokens = [reference_text.split()] # Reference should be wrapped in a list\n",
122
+ " predicted_tokens = predicted_text.split()\n",
123
+ "\n",
124
+ " # Add smoothing to handle cases with few n-gram matches\n",
125
+ " smoothing_function = SmoothingFunction().method1\n",
126
+ "\n",
127
+ " # Compute BLEU score\n",
128
+ " bleu_score = sentence_bleu(reference_tokens, predicted_tokens, smoothing_function=smoothing_function)\n",
129
+ " #print(\"The Computed bleu_score in the Compute_Blue Fn = \",bleu_score)\n",
130
+ " return round(bleu_score,2)\n",
131
+ "# Function to compute Word Error Rate (WER)\n",
132
+ "def compute_wer(reference_text, predicted_text):\n",
133
+ " \"\"\"\n",
134
+ " Computes the Word Error Rate (WER) for a single translation.\n",
135
+ " :param reference_text: The ground truth text (in Yoruba).\n",
136
+ " :param predicted_text: The machine-generated translation text (in Yoruba).\n",
137
+ " :return: WER score (float).\n",
138
+ " \"\"\"\n",
139
+ " # Normalize text: lowercase and remove punctuation\n",
140
+ " reference_text = reference_text.lower().translate(str.maketrans('', '', string.punctuation))\n",
141
+ " predicted_text = predicted_text.lower().translate(str.maketrans('', '', string.punctuation))\n",
142
+ "\n",
143
+ " # Compute WER\n",
144
+ " wer_score = wer(reference_text, predicted_text)\n",
145
+ "\n",
146
+ " return round(wer_score,2)\n",
147
+ "\n",
148
+ "# Function to compute METEOR score\n",
149
+ "def compute_meteor(reference_text, predicted_text):\n",
150
+ " \"\"\"\n",
151
+ " Computes the METEOR score for a single translation.\n",
152
+ " :param reference_text: The ground truth text (in Yoruba).\n",
153
+ " :param predicted_text: The machine-generated translation text (in Yoruba).\n",
154
+ " :return: METEOR score (float).\n",
155
+ " \"\"\"\n",
156
+ " # Normalize text: lowercase and remove punctuation\n",
157
+ " reference_text = reference_text.lower().translate(str.maketrans('', '', string.punctuation))\n",
158
+ " predicted_text = predicted_text.lower().translate(str.maketrans('', '', string.punctuation))\n",
159
+ "\n",
160
+ " # Tokenize text into lists of words\n",
161
+ " reference_tokens = reference_text.split()\n",
162
+ " predicted_tokens = predicted_text.split()\n",
163
+ "\n",
164
+ " # Compute METEOR score\n",
165
+ " meteor = meteor_score([reference_tokens], predicted_tokens)\n",
166
+ " \n",
167
+ " return round(meteor,2)\n",
168
+ "\n",
169
+ "# Function to compute Mel Cepstral Distance (MCD)\n",
170
+ "def compute_mcd(ground_truth_audio_path, predicted_audio_path):\n",
171
+ " \"\"\"\n",
172
+ " Computes the Mel Cepstral Distance (MCD) between two audio files.\n",
173
+ " :param ground_truth_audio_path: Path to the ground truth audio file.\n",
174
+ " :param predicted_audio_path: Path to the predicted audio file.\n",
175
+ " :return: MCD score (float).\n",
176
+ " \"\"\"\n",
177
+ " # Load audio files\n",
178
+ " y_true, sr_true = librosa.load(ground_truth_audio_path, sr=16000)\n",
179
+ " y_pred, sr_pred = librosa.load(predicted_audio_path, sr=16000)\n",
180
+ "\n",
181
+ " # Ensure the sampling rates match\n",
182
+ " assert sr_true == sr_pred, \"Sampling rates do not match between audio files.\"\n",
183
+ "\n",
184
+ " # Compute MFCCs\n",
185
+ " mfcc_true = librosa.feature.mfcc(y=y_true, sr=sr_true, n_mfcc=13).T\n",
186
+ " mfcc_pred = librosa.feature.mfcc(y=y_pred, sr=sr_pred, n_mfcc=13).T\n",
187
+ "\n",
188
+ " # Align the MFCC frames\n",
189
+ " min_frames = min(len(mfcc_true), len(mfcc_pred))\n",
190
+ " mfcc_true = mfcc_true[:min_frames]\n",
191
+ " mfcc_pred = mfcc_pred[:min_frames]\n",
192
+ "\n",
193
+ " # Compute the Euclidean distance for each frame and average\n",
194
+ " mcd = 0.0\n",
195
+ " for i in range(min_frames):\n",
196
+ " mcd += euclidean(mfcc_true[i], mfcc_pred[i])\n",
197
+ " mcd = (10.0 / np.log(10)) * (mcd / min_frames)\n",
198
+ "\n",
199
+ " return round(mcd,2)"
200
+ ]
201
+ },
202
+ {
203
+ "cell_type": "code",
204
+ "execution_count": 5,
205
+ "id": "69d64db9-b083-46ae-80ce-9616ba99183d",
206
+ "metadata": {
207
+ "editable": true,
208
+ "slideshow": {
209
+ "slide_type": ""
210
+ },
211
+ "tags": []
212
+ },
213
+ "outputs": [],
214
+ "source": [
215
+ "#Define Translation and Synthesis Function\n",
216
+ "def translate_transformers(modelName, sourceLangText):\n",
217
+ " #results = translation_pipeline(input_text)\n",
218
+ " translation_pipeline = pipeline('translation_en_to_yo', model = modelName, max_length=500)\n",
219
+ " translated_text = translation_pipeline(sourceLangText) #translator(text)[0][\"translation_text\"]\n",
220
+ " translated_text_target = translated_text[0]['translation_text']\n",
221
+ " #reference_translations = \"awon apositeli, awon woli, awon ajinrere ati awon oluso agutan ati awon oluko.\" #'recorder_2024-01-13_11-24-41_453538.wav'#\"My name is Joy, I love reading\"\n",
222
+ " \n",
223
+ " #TTS for the translated_text_target\n",
224
+ " #TTS Exp1\n",
225
+ " ttsModel = VitsModel.from_pretrained(\"facebook/mms-tts-yor\")\n",
226
+ " tokenizer = AutoTokenizer.from_pretrained(\"facebook/mms-tts-yor\")\n",
227
+ " ttsInputs = tokenizer(translated_text_target, return_tensors=\"pt\")\n",
228
+ " set_seed(555) # make deterministic\n",
229
+ " with torch.no_grad():\n",
230
+ " ttsOutput = ttsModel(**ttsInputs).waveform\n",
231
+ " #Convert the tensor to a numpy array\n",
232
+ " ttsWaveform = ttsOutput.numpy()[0] \n",
233
+ " #Save the waveform to an audio file\n",
234
+ " #sf.write('output.wav', waveform, 22050)\n",
235
+ " sf.write('ttsOutput.wav', ttsWaveform, 16000)\n",
236
+ " \n",
237
+ " # Sample ground truth and predicted text2text translations for Clinical Text\n",
238
+ " #ground_truth_text = \"Àrùn jẹjẹrẹ ọmú jẹ́ ọ̀kan pàtàkì lára ohun tó ń ṣàkóbá fún ìlera gbogbo ènìyàn ní Nàìjíríà, ó sì jẹ́ ọ̀kan pàtàkì lára ohun tó ń fa ikú àwọn obìnrin tí àrùn jẹjẹrẹ ń pa lórílẹ̀-èdè náà.\"\n",
239
+ " #predicted_text = translated_text_target #\"<extra_id_0> breast cancer is a\"\n",
240
+ "\n",
241
+ " # Sample ground truth and predicted text2text translations for News Text\n",
242
+ " #ground_truth_text = \"Wọ́n ní ìgbà àkọ́kọ́ nìyí tí irú ìwà ipá bẹ́ẹ̀ máa wáyé ní ìpínlẹ̀ Ondo.\"\n",
243
+ " #predicted_text = translated_text_target #\"<extra_id_0> breast cancer is a\"\n",
244
+ "\n",
245
+ " # Sample ground truth and predicted text2text translations for Religion Text\n",
246
+ " ground_truth_text = \"Àwọn aposteli, àwọn wòlíì, àwọn ajíhìnrere, àwọn olùṣọ́-àgùntàn àti àwọn olùkọ́.\"\n",
247
+ " predicted_text = translated_text_target #\"<extra_id_0> breast cancer is a\"\n",
248
+ " \n",
249
+ " #Compute bleu_score\n",
250
+ " bleu_score = compute_bleu(ground_truth_text, predicted_text)\n",
251
+ " print(f\"Bleu Score (BLEU): {bleu_score:.2f}\")\n",
252
+ " \n",
253
+ " #Compute WER\n",
254
+ " wer_score = compute_wer(ground_truth_text, predicted_text)\n",
255
+ " print(f\"Word Error Rate (WER): {wer_score:.2f}\")\n",
256
+ "\n",
257
+ " #Compute METEOR\n",
258
+ " meteor = compute_meteor(ground_truth_text, predicted_text)\n",
259
+ " print(f\"METEOR Score: {meteor:.2f}\")\n",
260
+ "\n",
261
+ " # Paths to sample audio files for MCD computation in current directory\n",
262
+ " ground_truth_audio = os.path.join(os.getcwd(), \"gt_ttsOutput.wav\")\n",
263
+ " predicted_audio = os.path.join(os.getcwd(), \"ttsOutput.wav\")\n",
264
+ "\n",
265
+ " # Compute Mel Cepstral Distance (MCD)\n",
266
+ " try:\n",
267
+ " mcd = compute_mcd(ground_truth_audio, predicted_audio)\n",
268
+ " print(f\"Mel Cepstral Distance (MCD): {mcd:.2f}\")\n",
269
+ " except Exception as e:\n",
270
+ " print(f\"Error computing MCD: {e}\")\n",
271
+ " \n",
272
+ " return translated_text_target,bleu_score,wer_score,meteor,mcd,'ttsOutput.wav'"
273
+ ]
274
+ },
275
+ {
276
+ "cell_type": "code",
277
+ "execution_count": 6,
278
+ "id": "bbf259d6-922d-4f5c-9af1-cbd57158a814",
279
+ "metadata": {
280
+ "editable": true,
281
+ "slideshow": {
282
+ "slide_type": ""
283
+ },
284
+ "tags": []
285
+ },
286
+ "outputs": [],
287
+ "source": [
288
+ "#Define User Interface Function using Gradio and IPython Libraries\n",
289
+ "import gradio as gr\n",
290
+ "from IPython.display import Audio\n",
291
+ "interface = gr.Interface(\n",
292
+ " fn=translate_transformers,\n",
293
+ " inputs=[\n",
294
+ " gr.Dropdown([\"Davlan/byt5-base-eng-yor-mt\", #Exp1\n",
295
+ " \"Davlan/m2m100_418M-eng-yor-mt\", #Exp2\n",
296
+ " \"Davlan/mbart50-large-eng-yor-mt\", #Exp3\n",
297
+ " \"Davlan/mt5_base_eng_yor_mt\", #Exp4\n",
298
+ " \"omoekan/opus-tatoeba-eng-yor\", #Exp5\n",
299
+ " \"masakhane/afrimt5_en_yor_news\", #Exp6\n",
300
+ " \"masakhane/afrimbart_en_yor_news\", #Exp7\n",
301
+ " \"masakhane/afribyt5_en_yor_news\", #Exp8\n",
302
+ " \"masakhane/byt5_en_yor_news\", #Exp9\n",
303
+ " \"masakhane/mt5_en_yor_news\", #Exp10\n",
304
+ " \"masakhane/mbart50_en_yor_news\", #Exp11\n",
305
+ " \"masakhane/m2m100_418M_en_yor_news\", #Exp12\n",
306
+ " \"masakhane/m2m100_418M_en_yor_rel_news\", #Exp13\n",
307
+ " \"masakhane/m2m100_418M_en_yor_rel_news_ft\", #Exp14\n",
308
+ " \"masakhane/m2m100_418M_en_yor_rel\", #Exp15\n",
309
+ " \"dabagyan/menyo_en2yo\", #Exp16\n",
310
+ " #\"facebook/nllb-200-distilled-600M\", #Exp17\n",
311
+ " #\"facebook/nllb-200-3.3B\", #Exp18\n",
312
+ " #\"facebook/nllb-200-1.3B\", #Exp19\n",
313
+ " #\"facebook/nllb-200-distilled-1.3B\", #Exp20\n",
314
+ " #\"keithhon/nllb-200-3.3B\" #Exp21\n",
315
+ " #\"CohereForAI/aya-101\" #Exp22\n",
316
+ " \"facebook/m2m100_418M\", #Exp17\n",
317
+ " #\"facebook/m2m100_1.2B\",#Exp18\n",
318
+ " #\"facebook/m2m100-12B-avg-5-ckpt\", #Exp19\n",
319
+ " \"google/mt5-base\", #Exp20\n",
320
+ " \"google/byt5-large\" #Exp21\n",
321
+ " ], \n",
322
+ " label=\"Select Finetuned Eng2Yor Translation Model\"),\n",
323
+ " gr.Textbox(lines=2, placeholder=\"Enter English Text Here...\", label=\"English Text\") \n",
324
+ " ],\n",
325
+ " #outputs = \"text\",\n",
326
+ " #outputs=outputs=[\"text\", \"text\"],#\"text\"\n",
327
+ " #outputs= gr.Textbox(value=\"text\", label=\"Translated Text\"),\n",
328
+ " outputs=[\n",
329
+ " gr.Textbox(value=\"text\", label=\"Translated Yoruba Text\"),\n",
330
+ " #gr.Textbox(value=\"text\", label=translated_text_actual),\n",
331
+ " gr.Textbox(value=\"number\", label=\"BLEU SCORE\"),\n",
332
+ " gr.Textbox(value=\"number\", label=\"WER(WORD ERROR RATE) SCORE - The Lower the Better\"),\n",
333
+ " gr.Textbox(value=\"number\", label=\"METEOR SCORE\"),\n",
334
+ " gr.Textbox(value=\"number\", label=\"MCD(MEL CESPRAL DISTANCE) SCORE\"),\n",
335
+ " gr.Audio(type=\"filepath\", label=\"Click to Generate Yoruba Speech from the Translated Text\")\n",
336
+ " ],\n",
337
+ " title=\"ASPMIR-MACHINE-TRANSLATION-TESTBED FOR LOW RESOURCED AFRICAN LANGUAGES\",\n",
338
+ " #gr.Markdown(\"**This Tool Allows Developers and Researchers to Carry Out Experiments on Low Resourced African Languages with State-of-the-Art NMT Finetuned Models.**\"),\n",
339
+ " description=\"{This Tool Allows Developers and Researchers to Carry Out Experiments on Low Resourced African Languages with State-of-the-Art Pretrained or Finetuned Models.}\"\n",
340
+ ")\n",
341
+ "#interface.launch(share=True)\n"
342
+ ]
343
+ },
344
+ {
345
+ "cell_type": "code",
346
+ "execution_count": 7,
347
+ "id": "c3baee0f-fd85-4209-9d54-14451abd372a",
348
+ "metadata": {
349
+ "scrolled": true
350
+ },
351
+ "outputs": [
352
+ {
353
+ "name": "stdout",
354
+ "output_type": "stream",
355
+ "text": [
356
+ "* Running on local URL: http://127.0.0.1:7860\n",
357
+ "* Running on public URL: https://c18533aae56f5e43a5.gradio.live\n",
358
+ "\n",
359
+ "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n"
360
+ ]
361
+ },
362
+ {
363
+ "data": {
364
+ "text/html": [
365
+ "<div><iframe src=\"https://c18533aae56f5e43a5.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
366
+ ],
367
+ "text/plain": [
368
+ "<IPython.core.display.HTML object>"
369
+ ]
370
+ },
371
+ "metadata": {},
372
+ "output_type": "display_data"
373
+ }
374
+ ],
375
+ "source": [
376
+ "if __name__ == \"__main__\":\n",
377
+ " interface.launch(share=True)"
378
+ ]
379
+ }
380
+ ],
381
+ "metadata": {
382
+ "kernelspec": {
383
+ "display_name": "Python 3 (ipykernel)",
384
+ "language": "python",
385
+ "name": "python3"
386
+ },
387
+ "language_info": {
388
+ "codemirror_mode": {
389
+ "name": "ipython",
390
+ "version": 3
391
+ },
392
+ "file_extension": ".py",
393
+ "mimetype": "text/x-python",
394
+ "name": "python",
395
+ "nbconvert_exporter": "python",
396
+ "pygments_lexer": "ipython3",
397
+ "version": "3.10.10"
398
+ }
399
+ },
400
+ "nbformat": 4,
401
+ "nbformat_minor": 5
402
+ }
ASPMIR-YorTTS.py ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # In[1]:
5
+
6
+
7
+ #Install All the Required Dependencies
8
+ #!pip3 install torch torchvision torchaudio
9
+ #!pip install transformers ipywidgets gradio --upgrade
10
+ #!pip install --upgrade transformers accelerate
11
+ #!pip install --upgrade gradio
12
+ #!pip install nltk
13
+ #!pip install jiwer
14
+ #!pip install sentencepiece
15
+ #!pip install sacremoses
16
+ #!pip install soundfile
17
+ #!pip install librosa numpy jiwer nltk
18
+ #!pip install --upgrade pip
19
+ #!pip install huggingface_hub
20
+
21
+
22
+ # In[2]:
23
+
24
+
25
+ #Import Required Libraries
26
+ from transformers import pipeline
27
+ from jiwer import wer
28
+ from transformers import VitsModel, AutoTokenizer, set_seed
29
+ import torch
30
+ import soundfile as sf
31
+ import librosa
32
+ from scipy.spatial.distance import euclidean
33
+ import numpy as np
34
+ import string
35
+ import os
36
+ from nltk.translate.bleu_score import sentence_bleu, SmoothingFunction
37
+ from nltk.translate.meteor_score import meteor_score
38
+ import string
39
+ import numpy as np
40
+ import librosa
41
+ from scipy.spatial.distance import euclidean
42
+ import string
43
+
44
+
45
+ # In[3]:
46
+
47
+
48
+ import nltk
49
+ nltk.download('wordnet')
50
+ nltk.download('omw-1.4') # Optional if using WordNet's multilingual features
51
+ import nltk
52
+ print(nltk.data.path)
53
+ import nltk
54
+ nltk.data.path.append('./nltk_data')
55
+
56
+
57
+ # In[4]:
58
+
59
+
60
+ #Define all Utility Functions
61
+ # Function to compute BLEU score
62
+ def compute_bleu(reference_text, predicted_text):
63
+ """
64
+ Computes the BLEU score for a single translation.
65
+ :param reference_text: The ground truth text (in Yoruba).
66
+ :param predicted_text: The machine-generated translation text (in Yoruba).
67
+ :return: BLEU score (float).
68
+ """
69
+ print("The Reference Text = ", reference_text)
70
+ print("The Predicted Text = ",predicted_text)
71
+ # Tokenize the reference and predicted texts
72
+ reference_tokens = [reference_text.split()] # Reference should be wrapped in a list
73
+ predicted_tokens = predicted_text.split()
74
+
75
+ # Add smoothing to handle cases with few n-gram matches
76
+ smoothing_function = SmoothingFunction().method1
77
+
78
+ # Compute BLEU score
79
+ bleu_score = sentence_bleu(reference_tokens, predicted_tokens, smoothing_function=smoothing_function)
80
+ #print("The Computed bleu_score in the Compute_Blue Fn = ",bleu_score)
81
+ return round(bleu_score,2)
82
+ # Function to compute Word Error Rate (WER)
83
+ def compute_wer(reference_text, predicted_text):
84
+ """
85
+ Computes the Word Error Rate (WER) for a single translation.
86
+ :param reference_text: The ground truth text (in Yoruba).
87
+ :param predicted_text: The machine-generated translation text (in Yoruba).
88
+ :return: WER score (float).
89
+ """
90
+ # Normalize text: lowercase and remove punctuation
91
+ reference_text = reference_text.lower().translate(str.maketrans('', '', string.punctuation))
92
+ predicted_text = predicted_text.lower().translate(str.maketrans('', '', string.punctuation))
93
+
94
+ # Compute WER
95
+ wer_score = wer(reference_text, predicted_text)
96
+
97
+ return round(wer_score,2)
98
+
99
+ # Function to compute METEOR score
100
+ def compute_meteor(reference_text, predicted_text):
101
+ """
102
+ Computes the METEOR score for a single translation.
103
+ :param reference_text: The ground truth text (in Yoruba).
104
+ :param predicted_text: The machine-generated translation text (in Yoruba).
105
+ :return: METEOR score (float).
106
+ """
107
+ # Normalize text: lowercase and remove punctuation
108
+ reference_text = reference_text.lower().translate(str.maketrans('', '', string.punctuation))
109
+ predicted_text = predicted_text.lower().translate(str.maketrans('', '', string.punctuation))
110
+
111
+ # Tokenize text into lists of words
112
+ reference_tokens = reference_text.split()
113
+ predicted_tokens = predicted_text.split()
114
+
115
+ # Compute METEOR score
116
+ meteor = meteor_score([reference_tokens], predicted_tokens)
117
+
118
+ return round(meteor,2)
119
+
120
+ # Function to compute Mel Cepstral Distance (MCD)
121
+ def compute_mcd(ground_truth_audio_path, predicted_audio_path):
122
+ """
123
+ Computes the Mel Cepstral Distance (MCD) between two audio files.
124
+ :param ground_truth_audio_path: Path to the ground truth audio file.
125
+ :param predicted_audio_path: Path to the predicted audio file.
126
+ :return: MCD score (float).
127
+ """
128
+ # Load audio files
129
+ y_true, sr_true = librosa.load(ground_truth_audio_path, sr=16000)
130
+ y_pred, sr_pred = librosa.load(predicted_audio_path, sr=16000)
131
+
132
+ # Ensure the sampling rates match
133
+ assert sr_true == sr_pred, "Sampling rates do not match between audio files."
134
+
135
+ # Compute MFCCs
136
+ mfcc_true = librosa.feature.mfcc(y=y_true, sr=sr_true, n_mfcc=13).T
137
+ mfcc_pred = librosa.feature.mfcc(y=y_pred, sr=sr_pred, n_mfcc=13).T
138
+
139
+ # Align the MFCC frames
140
+ min_frames = min(len(mfcc_true), len(mfcc_pred))
141
+ mfcc_true = mfcc_true[:min_frames]
142
+ mfcc_pred = mfcc_pred[:min_frames]
143
+
144
+ # Compute the Euclidean distance for each frame and average
145
+ mcd = 0.0
146
+ for i in range(min_frames):
147
+ mcd += euclidean(mfcc_true[i], mfcc_pred[i])
148
+ mcd = (10.0 / np.log(10)) * (mcd / min_frames)
149
+
150
+ return round(mcd,2)
151
+
152
+
153
+ # In[5]:
154
+
155
+
156
+ #Define Translation and Synthesis Function
157
+ def translate_transformers(modelName, sourceLangText):
158
+ #results = translation_pipeline(input_text)
159
+ translation_pipeline = pipeline('translation_en_to_yo', model = modelName, max_length=500)
160
+ translated_text = translation_pipeline(sourceLangText) #translator(text)[0]["translation_text"]
161
+ translated_text_target = translated_text[0]['translation_text']
162
+ #reference_translations = "awon apositeli, awon woli, awon ajinrere ati awon oluso agutan ati awon oluko." #'recorder_2024-01-13_11-24-41_453538.wav'#"My name is Joy, I love reading"
163
+
164
+ #TTS for the translated_text_target
165
+ #TTS Exp1
166
+ ttsModel = VitsModel.from_pretrained("facebook/mms-tts-yor")
167
+ tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-yor")
168
+ ttsInputs = tokenizer(translated_text_target, return_tensors="pt")
169
+ set_seed(555) # make deterministic
170
+ with torch.no_grad():
171
+ ttsOutput = ttsModel(**ttsInputs).waveform
172
+ #Convert the tensor to a numpy array
173
+ ttsWaveform = ttsOutput.numpy()[0]
174
+ #Save the waveform to an audio file
175
+ #sf.write('output.wav', waveform, 22050)
176
+ sf.write('ttsOutput.wav', ttsWaveform, 16000)
177
+
178
+ # Sample ground truth and predicted text2text translations for Clinical Text
179
+ #ground_truth_text = "Àrùn jẹjẹrẹ ọmú jẹ́ ọ̀kan pàtàkì lára ohun tó ń ṣàkóbá fún ìlera gbogbo ènìyàn ní Nàìjíríà, ó sì jẹ́ ọ̀kan pàtàkì lára ohun tó ń fa ikú àwọn obìnrin tí àrùn jẹjẹrẹ ń pa lórílẹ̀-èdè náà."
180
+ #predicted_text = translated_text_target #"<extra_id_0> breast cancer is a"
181
+
182
+ # Sample ground truth and predicted text2text translations for News Text
183
+ #ground_truth_text = "Wọ́n ní ìgbà àkọ́kọ́ nìyí tí irú ìwà ipá bẹ́ẹ̀ máa wáyé ní ìpínlẹ̀ Ondo."
184
+ #predicted_text = translated_text_target #"<extra_id_0> breast cancer is a"
185
+
186
+ # Sample ground truth and predicted text2text translations for Religion Text
187
+ ground_truth_text = "Àwọn aposteli, àwọn wòlíì, àwọn ajíhìnrere, àwọn olùṣọ́-àgùntàn àti àwọn olùkọ́."
188
+ predicted_text = translated_text_target #"<extra_id_0> breast cancer is a"
189
+
190
+ #Compute bleu_score
191
+ bleu_score = compute_bleu(ground_truth_text, predicted_text)
192
+ print(f"Bleu Score (BLEU): {bleu_score:.2f}")
193
+
194
+ #Compute WER
195
+ wer_score = compute_wer(ground_truth_text, predicted_text)
196
+ print(f"Word Error Rate (WER): {wer_score:.2f}")
197
+
198
+ #Compute METEOR
199
+ meteor = compute_meteor(ground_truth_text, predicted_text)
200
+ print(f"METEOR Score: {meteor:.2f}")
201
+
202
+ # Paths to sample audio files for MCD computation in current directory
203
+ ground_truth_audio = os.path.join(os.getcwd(), "gt_ttsOutput.wav")
204
+ predicted_audio = os.path.join(os.getcwd(), "ttsOutput.wav")
205
+
206
+ # Compute Mel Cepstral Distance (MCD)
207
+ try:
208
+ mcd = compute_mcd(ground_truth_audio, predicted_audio)
209
+ print(f"Mel Cepstral Distance (MCD): {mcd:.2f}")
210
+ except Exception as e:
211
+ print(f"Error computing MCD: {e}")
212
+
213
+ return translated_text_target,bleu_score,wer_score,meteor,mcd,'ttsOutput.wav'
214
+
215
+
216
+ # In[6]:
217
+
218
+
219
+ #Define User Interface Function using Gradio and IPython Libraries
220
+ import gradio as gr
221
+ from IPython.display import Audio
222
+ interface = gr.Interface(
223
+ fn=translate_transformers,
224
+ inputs=[
225
+ gr.Dropdown(["Davlan/byt5-base-eng-yor-mt", #Exp1
226
+ "Davlan/m2m100_418M-eng-yor-mt", #Exp2
227
+ "Davlan/mbart50-large-eng-yor-mt", #Exp3
228
+ "Davlan/mt5_base_eng_yor_mt", #Exp4
229
+ "omoekan/opus-tatoeba-eng-yor", #Exp5
230
+ "masakhane/afrimt5_en_yor_news", #Exp6
231
+ "masakhane/afrimbart_en_yor_news", #Exp7
232
+ "masakhane/afribyt5_en_yor_news", #Exp8
233
+ "masakhane/byt5_en_yor_news", #Exp9
234
+ "masakhane/mt5_en_yor_news", #Exp10
235
+ "masakhane/mbart50_en_yor_news", #Exp11
236
+ "masakhane/m2m100_418M_en_yor_news", #Exp12
237
+ "masakhane/m2m100_418M_en_yor_rel_news", #Exp13
238
+ "masakhane/m2m100_418M_en_yor_rel_news_ft", #Exp14
239
+ "masakhane/m2m100_418M_en_yor_rel", #Exp15
240
+ "dabagyan/menyo_en2yo", #Exp16
241
+ #"facebook/nllb-200-distilled-600M", #Exp17
242
+ #"facebook/nllb-200-3.3B", #Exp18
243
+ #"facebook/nllb-200-1.3B", #Exp19
244
+ #"facebook/nllb-200-distilled-1.3B", #Exp20
245
+ #"keithhon/nllb-200-3.3B" #Exp21
246
+ #"CohereForAI/aya-101" #Exp22
247
+ "facebook/m2m100_418M", #Exp17
248
+ #"facebook/m2m100_1.2B",#Exp18
249
+ #"facebook/m2m100-12B-avg-5-ckpt", #Exp19
250
+ "google/mt5-base", #Exp20
251
+ "google/byt5-large" #Exp21
252
+ ],
253
+ label="Select Finetuned Eng2Yor Translation Model"),
254
+ gr.Textbox(lines=2, placeholder="Enter English Text Here...", label="English Text")
255
+ ],
256
+ #outputs = "text",
257
+ #outputs=outputs=["text", "text"],#"text"
258
+ #outputs= gr.Textbox(value="text", label="Translated Text"),
259
+ outputs=[
260
+ gr.Textbox(value="text", label="Translated Yoruba Text"),
261
+ #gr.Textbox(value="text", label=translated_text_actual),
262
+ gr.Textbox(value="number", label="BLEU SCORE"),
263
+ gr.Textbox(value="number", label="WER(WORD ERROR RATE) SCORE - The Lower the Better"),
264
+ gr.Textbox(value="number", label="METEOR SCORE"),
265
+ gr.Textbox(value="number", label="MCD(MEL CESPRAL DISTANCE) SCORE"),
266
+ gr.Audio(type="filepath", label="Click to Generate Yoruba Speech from the Translated Text")
267
+ ],
268
+ title="ASPMIR-MACHINE-TRANSLATION-TESTBED FOR LOW RESOURCED AFRICAN LANGUAGES",
269
+ #gr.Markdown("**This Tool Allows Developers and Researchers to Carry Out Experiments on Low Resourced African Languages with State-of-the-Art NMT Finetuned Models.**"),
270
+ description="{This Tool Allows Developers and Researchers to Carry Out Experiments on Low Resourced African Languages with State-of-the-Art Pretrained or Finetuned Models.}"
271
+ )
272
+ #interface.launch(share=True)
273
+
274
+
275
+ # In[7]:
276
+
277
+
278
+ if __name__ == "__main__":
279
+ interface.launch(share=True)
280
+
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: ASPMIR-NMTNEURAL MACHINE TRANSLATION TESTBED
3
- emoji: 📈
4
- colorFrom: blue
5
- colorTo: red
6
  sdk: gradio
7
- sdk_version: 5.9.1
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: ASPMIR-NMTNEURAL_MACHINE_TRANSLATION_TESTBED
3
+ app_file: ASPMIR-YorTTS.py
 
 
4
  sdk: gradio
5
+ sdk_version: 5.8.0
 
 
6
  ---
 
 
flagged/Click to Generate Yoruba Text2Speech/68242da6366a05c83761/ttsOutput.wav ADDED
Binary file (430 kB). View file
 
flagged/Click to Generate Yoruba Text2Speech/a8120a29323143cfc3fa/ttsOutput.wav ADDED
Binary file (25.1 kB). View file
 
flagged/log.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Select Finetuned Eng2Yor Translation Model,English Text,Translated Yoruba Text,WER(Word Error Rate) Score - The Lower the Better,Click to Generate Yoruba Text2Speech,flag,username,timestamp
2
+ masakhane/m2m100_418M_en_yor_news,Recent research has been carried out and revealed that using contraceptives to prevent pregnancy is one of the major causes of breast cancer in the country. All contraceptives sometimes lead to cancer and they are not safe for human consumption,Ìwádìí tí ó ṣẹlẹ̀ ní àìpẹ́ yìí ti fi hàn wípé gbígba ẹ̀dọ̀ tí ó fi dènà àìsàn jẹ́ ọ̀kan lára ohun tí ó ń fa àrùn abẹ ní orílẹ̀-èdè náà. Gbogbo ẹ̀dọ̀ tí ó fi dènà ẹ̀dọ̀ jẹ́ nígbà mìíràn kò sì jẹ́ àbò fún ènìyàn.,1.0,"{""path"":""flagged/Click to Generate Yoruba Text2Speech/68242da6366a05c83761/ttsOutput.wav"",""url"":""https://142dc3e73226f2a320.gradio.live/file=/tmp/gradio/37e7a6078ed13ae05feac2da7f3c0bbe40fb9c91/ttsOutput.wav"",""size"":null,""orig_name"":""ttsOutput.wav"",""mime_type"":null,""is_stream"":false}",,,2024-03-21 13:22:16.576832
3
+ masakhane/m2m100_418M_en_yor_news,How are you,Báwo ni ẹ̀,2.3333333333333335,"{""path"":""flagged/Click to Generate Yoruba Text2Speech/a8120a29323143cfc3fa/ttsOutput.wav"",""url"":""https://142dc3e73226f2a320.gradio.live/file=/tmp/gradio/7625e41f2f7dfe12b18f4ebcb87722ebff349d6d/ttsOutput.wav"",""size"":null,""orig_name"":""ttsOutput.wav"",""mime_type"":null,""is_stream"":false}",,,2024-03-21 13:50:31.879816
4
+ Davlan/m2m100_418M-eng-yor-mt,"My name is Joy, I love programming",text,number,,,,2024-05-17 21:37:06.460794
gt_ttsOutput.wav ADDED
Binary file (140 kB). View file
 
requirements.txt ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pip>=24.3.1
2
+ absl-py==1.4.0
3
+ accelerate==1.2.0
4
+ aiofiles==23.2.1
5
+ aiohttp==3.9.0
6
+ aiohttp-cors==0.7.0
7
+ aiosignal==1.3.1
8
+ alembic==1.12.1
9
+ altair==5.2.0
10
+ annotated-types==0.6.0
11
+ anyio==4.0.0
12
+ argon2-cffi==23.1.0
13
+ argon2-cffi-bindings==21.2.0
14
+ array-record==0.5.0
15
+ arrow==1.3.0
16
+ asttokens==2.4.1
17
+ astunparse==1.6.3
18
+ async-generator==1.10
19
+ async-lru==2.0.4
20
+ async-timeout==4.0.3
21
+ attrs==23.1.0
22
+ audioread==3.0.1
23
+ Babel==2.13.1
24
+ beautifulsoup4==4.12.2
25
+ bleach==6.1.0
26
+ blessed==1.20.0
27
+ brotlipy==0.7.0
28
+ cachetools==5.3.2
29
+ certifi
30
+ certipy==0.1.3
31
+ cffi
32
+ charset-normalizer
33
+ click==8.1.7
34
+ colorama
35
+ colorful==0.5.5
36
+ comm==0.2.0
37
+ conda-package-handling
38
+ conda_package_streaming
39
+ contourpy==1.2.0
40
+ cryptography
41
+ cycler==0.12.1
42
+ debugpy==1.8.0
43
+ decorator==5.1.1
44
+ defusedxml==0.7.1
45
+ distlib==0.3.7
46
+ dm-tree==0.1.8
47
+ et-xmlfile==1.1.0
48
+ etils==1.6.0
49
+ exceptiongroup==1.1.3
50
+ executing==2.0.1
51
+ fastapi==0.115.6
52
+ fastjsonschema==2.19.0
53
+ ffmpy==0.3.1
54
+ filelock
55
+ flatbuffers==23.5.26
56
+ fonttools==4.44.3
57
+ fqdn==1.5.1
58
+ frozenlist==1.4.0
59
+ fsspec==2024.2.0
60
+ gast==0.5.4
61
+ gmpy2
62
+ google-api-core==2.14.0
63
+ google-auth==2.23.4
64
+ google-auth-oauthlib==1.1.0
65
+ google-pasta==0.2.0
66
+ googleapis-common-protos==1.61.0
67
+ gpustat==1.1.1
68
+ gradio==5.8.0
69
+ gradio_client==1.5.1
70
+ greenlet==3.0.1
71
+ grpcio==1.59.3
72
+ gTTS==2.5.1
73
+ h11==0.14.0
74
+ h5py==3.10.0
75
+ httpcore==1.0.2
76
+ httpx==0.26.0
77
+ huggingface-hub==0.26.3
78
+ idna
79
+ ipykernel==6.26.0
80
+ ipython==8.17.2
81
+ ipywidgets==8.1.2
82
+ isoduration==20.11.0
83
+ jedi==0.19.1
84
+ Jinja2
85
+ jiwer==3.0.3
86
+ joblib
87
+ json5==0.9.14
88
+ jsonpatch
89
+ jsonpointer
90
+ jsonschema==4.20.0
91
+ jsonschema-specifications==2023.11.1
92
+ jupyter-events==0.9.0
93
+ jupyter-lsp==2.2.0
94
+ jupyter-resource-usage==1.0.1
95
+ jupyter-telemetry==0.1.0
96
+ jupyter_client==8.6.0
97
+ jupyter_core==5.5.0
98
+ jupyter_server==2.10.1
99
+ jupyter_server_terminals==0.4.4
100
+ jupyterhub==4.0.2
101
+ jupyterlab==4.0.9
102
+ jupyterlab-pygments==0.2.2
103
+ jupyterlab_server==2.25.2
104
+ jupyterlab_widgets==3.0.10
105
+ keras==2.15.0
106
+ librosa==0.10.2.post1
107
+ nltk==3.8.1
108
+ notebook==7.0.6
109
+ notebook_shim==0.2.3
110
+ numba==0.60.0
111
+ numpy
112
+ nvidia-cublas-cu12==12.1.3.1
113
+ nvidia-cuda-cupti-cu12==12.1.105
114
+ nvidia-cuda-nvcc-cu12==12.2.140
115
+ nvidia-cuda-nvrtc-cu12==12.1.105
116
+ nvidia-cuda-runtime-cu12==12.1.105
117
+ nvidia-cudnn-cu12==8.9.2.26
118
+ nvidia-cufft-cu12==11.0.2.54
119
+ nvidia-curand-cu12==10.3.2.106
120
+ nvidia-cusolver-cu12==11.4.5.107
121
+ nvidia-cusparse-cu12==12.1.0.106
122
+ nvidia-ml-py==12.535.133
123
+ nvidia-nccl-cu12==2.20.5
124
+ nvidia-nvjitlink-cu12==12.2.140
125
+ nvidia-nvtx-cu12==12.1.105
126
+ oauthlib==3.2.2
127
+ scapy==2.5.0
128
+ scikit-learn
129
+ scipy
130
+ SentencePiece
131
+ soundfile==0.12.1
132
+ tensorboard==2.15.1
133
+ tensorboard-data-server==0.7.2
134
+ tensorflow==2.15.0.post1
135
+ tensorflow-estimator==2.15.0
136
+ tensorflow-io-gcs-filesystem==0.34.0
137
+ tensorflow-metadata==1.14.0
138
+ transformers
139
+ torch==2.3.1
140
+ uri-template==1.3.0
141
+ urllib3==2.2.1
142
+ widgetsnbextension==4.0.10
143
+
ttsOutput.wav ADDED
Binary file (130 kB). View file