Spaces:
Runtime error
Runtime error
betheredge
commited on
Commit
·
c17f48e
1
Parent(s):
26e38b9
init spaces
Browse files- Dockerfile +14 -0
- README.md +1 -1
- docker-compose.yml +9 -0
- notebooks/eda.ipynb +87 -0
- requirements.in +13 -0
- requirements.txt +284 -0
- src/app.py +86 -0
- src/requirements.in +16 -0
- src/requirements.txt +420 -0
Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.8
|
2 |
+
|
3 |
+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
4 |
+
&& apt-get -y install --no-install-recommends ffmpeg \
|
5 |
+
&& rm -rf /var/lib/apt/lists/*
|
6 |
+
|
7 |
+
COPY requirements.txt /tmp/pip-tmp/
|
8 |
+
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
|
9 |
+
&& rm -rf /tmp/pip-tmp
|
10 |
+
|
11 |
+
COPY src/ /app/
|
12 |
+
|
13 |
+
WORKDIR /app
|
14 |
+
RUN python app.py
|
README.md
CHANGED
@@ -5,7 +5,7 @@ colorFrom: indigo
|
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.1.1
|
8 |
-
app_file: app.py
|
9 |
pinned: false
|
10 |
license: gpl-3.0
|
11 |
---
|
|
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.1.1
|
8 |
+
app_file: src/app.py
|
9 |
pinned: false
|
10 |
license: gpl-3.0
|
11 |
---
|
docker-compose.yml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: "3.9"
|
2 |
+
|
3 |
+
services:
|
4 |
+
app:
|
5 |
+
build: .
|
6 |
+
ports:
|
7 |
+
- "7860:7860"
|
8 |
+
volumes:
|
9 |
+
- $flagging_dir:/app/flagging
|
notebooks/eda.ipynb
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import json\n",
|
10 |
+
"import requests\n",
|
11 |
+
"import os\n",
|
12 |
+
"API_TOKEN = os.environ[\"API_TOKEN\"]\n",
|
13 |
+
"headers = {\"Authorization\": f\"Bearer {API_TOKEN}\"}\n",
|
14 |
+
"API_URL = \"https://api-inference.huggingface.co/models/facebook/wav2vec2-base-960h\"\n",
|
15 |
+
"\n",
|
16 |
+
"def query(filename):\n",
|
17 |
+
" with open(filename, \"rb\") as f:\n",
|
18 |
+
" data = f.read()\n",
|
19 |
+
" response = requests.request(\"POST\", API_URL, headers=headers, data=data)\n",
|
20 |
+
" return json.loads(response.content.decode(\"utf-8\"))\n",
|
21 |
+
"\n",
|
22 |
+
"data = query(\"test.wav\")\n",
|
23 |
+
"\n"
|
24 |
+
]
|
25 |
+
},
|
26 |
+
{
|
27 |
+
"cell_type": "code",
|
28 |
+
"execution_count": null,
|
29 |
+
"metadata": {},
|
30 |
+
"outputs": [],
|
31 |
+
"source": [
|
32 |
+
"data"
|
33 |
+
]
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"cell_type": "code",
|
37 |
+
"execution_count": null,
|
38 |
+
"metadata": {},
|
39 |
+
"outputs": [],
|
40 |
+
"source": [
|
41 |
+
"from transformers import pipeline\n",
|
42 |
+
"\n",
|
43 |
+
"with open(\"test.wav\", \"rb\") as f:\n",
|
44 |
+
" data = f.read()\n",
|
45 |
+
"\n",
|
46 |
+
"pipe = pipeline(\"automatic-speech-recognition\", \"facebook/wav2vec2-base-960h\")\n",
|
47 |
+
"pipe(\"test.wav\")\n",
|
48 |
+
"# {'text': \"GOING ALONG SLUSHY COUNTRY ROADS AND SPEAKING TO DAMP AUDIENCES IN DRAUGHTY SCHOOL ROOMS DAY AFTER DAY FOR A FORTNIGHT HE'LL HAVE TO PUT IN AN APPEARANCE AT SOME PLACE OF WORSHIP ON SUNDAY MORNING AND HE CAN COME TO US IMMEDIATELY AFTERWARDS\"}\n",
|
49 |
+
"\n"
|
50 |
+
]
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"cell_type": "code",
|
54 |
+
"execution_count": null,
|
55 |
+
"metadata": {},
|
56 |
+
"outputs": [],
|
57 |
+
"source": []
|
58 |
+
}
|
59 |
+
],
|
60 |
+
"metadata": {
|
61 |
+
"kernelspec": {
|
62 |
+
"display_name": "Python 3.8.13 64-bit",
|
63 |
+
"language": "python",
|
64 |
+
"name": "python3"
|
65 |
+
},
|
66 |
+
"language_info": {
|
67 |
+
"codemirror_mode": {
|
68 |
+
"name": "ipython",
|
69 |
+
"version": 3
|
70 |
+
},
|
71 |
+
"file_extension": ".py",
|
72 |
+
"mimetype": "text/x-python",
|
73 |
+
"name": "python",
|
74 |
+
"nbconvert_exporter": "python",
|
75 |
+
"pygments_lexer": "ipython3",
|
76 |
+
"version": "3.8.13"
|
77 |
+
},
|
78 |
+
"orig_nbformat": 4,
|
79 |
+
"vscode": {
|
80 |
+
"interpreter": {
|
81 |
+
"hash": "949777d72b0d2535278d3dc13498b2535136f6dfe0678499012e853ee9abcab1"
|
82 |
+
}
|
83 |
+
}
|
84 |
+
},
|
85 |
+
"nbformat": 4,
|
86 |
+
"nbformat_minor": 2
|
87 |
+
}
|
requirements.in
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
torchvision
|
3 |
+
torchaudio
|
4 |
+
# --extra-index-url https://download.pytorch.org/whl/cu116
|
5 |
+
|
6 |
+
pytorch-lightning
|
7 |
+
transformers
|
8 |
+
numpy
|
9 |
+
gradio
|
10 |
+
|
11 |
+
# punctuation
|
12 |
+
deepmultilingualpunctuation
|
13 |
+
sentencepiece
|
requirements.txt
ADDED
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# This file is autogenerated by pip-compile with python 3.8
|
3 |
+
# To update, run:
|
4 |
+
#
|
5 |
+
# pip-compile
|
6 |
+
#
|
7 |
+
absl-py==1.2.0
|
8 |
+
# via tensorboard
|
9 |
+
aiohttp==3.8.1
|
10 |
+
# via
|
11 |
+
# fsspec
|
12 |
+
# gradio
|
13 |
+
aiosignal==1.2.0
|
14 |
+
# via aiohttp
|
15 |
+
analytics-python==1.4.0
|
16 |
+
# via gradio
|
17 |
+
anyio==3.6.1
|
18 |
+
# via
|
19 |
+
# httpcore
|
20 |
+
# starlette
|
21 |
+
async-timeout==4.0.2
|
22 |
+
# via aiohttp
|
23 |
+
attrs==21.4.0
|
24 |
+
# via aiohttp
|
25 |
+
backoff==1.10.0
|
26 |
+
# via analytics-python
|
27 |
+
bcrypt==3.2.2
|
28 |
+
# via paramiko
|
29 |
+
cachetools==5.2.0
|
30 |
+
# via google-auth
|
31 |
+
certifi==2022.6.15
|
32 |
+
# via
|
33 |
+
# httpcore
|
34 |
+
# httpx
|
35 |
+
# requests
|
36 |
+
cffi==1.15.1
|
37 |
+
# via
|
38 |
+
# bcrypt
|
39 |
+
# cryptography
|
40 |
+
# pynacl
|
41 |
+
charset-normalizer==2.1.0
|
42 |
+
# via
|
43 |
+
# aiohttp
|
44 |
+
# requests
|
45 |
+
click==8.1.3
|
46 |
+
# via uvicorn
|
47 |
+
cryptography==37.0.4
|
48 |
+
# via paramiko
|
49 |
+
cycler==0.11.0
|
50 |
+
# via matplotlib
|
51 |
+
fastapi==0.79.0
|
52 |
+
# via gradio
|
53 |
+
ffmpy==0.3.0
|
54 |
+
# via gradio
|
55 |
+
filelock==3.7.1
|
56 |
+
# via
|
57 |
+
# huggingface-hub
|
58 |
+
# transformers
|
59 |
+
fonttools==4.34.4
|
60 |
+
# via matplotlib
|
61 |
+
frozenlist==1.3.0
|
62 |
+
# via
|
63 |
+
# aiohttp
|
64 |
+
# aiosignal
|
65 |
+
fsspec[http]==2022.5.0
|
66 |
+
# via
|
67 |
+
# gradio
|
68 |
+
# pytorch-lightning
|
69 |
+
google-auth==2.9.1
|
70 |
+
# via
|
71 |
+
# google-auth-oauthlib
|
72 |
+
# tensorboard
|
73 |
+
google-auth-oauthlib==0.4.6
|
74 |
+
# via tensorboard
|
75 |
+
gradio==3.1.1
|
76 |
+
# via -r requirements.in
|
77 |
+
grpcio==1.47.0
|
78 |
+
# via tensorboard
|
79 |
+
h11==0.12.0
|
80 |
+
# via
|
81 |
+
# gradio
|
82 |
+
# httpcore
|
83 |
+
# uvicorn
|
84 |
+
httpcore==0.15.0
|
85 |
+
# via httpx
|
86 |
+
httpx==0.23.0
|
87 |
+
# via gradio
|
88 |
+
huggingface-hub==0.8.1
|
89 |
+
# via transformers
|
90 |
+
idna==3.3
|
91 |
+
# via
|
92 |
+
# anyio
|
93 |
+
# requests
|
94 |
+
# rfc3986
|
95 |
+
# yarl
|
96 |
+
importlib-metadata==4.12.0
|
97 |
+
# via markdown
|
98 |
+
jinja2==3.1.2
|
99 |
+
# via gradio
|
100 |
+
kiwisolver==1.4.4
|
101 |
+
# via matplotlib
|
102 |
+
linkify-it-py==1.0.3
|
103 |
+
# via markdown-it-py
|
104 |
+
markdown==3.4.1
|
105 |
+
# via tensorboard
|
106 |
+
markdown-it-py[linkify,plugins]==2.1.0
|
107 |
+
# via
|
108 |
+
# gradio
|
109 |
+
# mdit-py-plugins
|
110 |
+
markupsafe==2.1.1
|
111 |
+
# via jinja2
|
112 |
+
matplotlib==3.5.2
|
113 |
+
# via gradio
|
114 |
+
mdit-py-plugins==0.3.0
|
115 |
+
# via markdown-it-py
|
116 |
+
mdurl==0.1.1
|
117 |
+
# via markdown-it-py
|
118 |
+
monotonic==1.6
|
119 |
+
# via analytics-python
|
120 |
+
multidict==6.0.2
|
121 |
+
# via
|
122 |
+
# aiohttp
|
123 |
+
# yarl
|
124 |
+
numpy==1.23.1
|
125 |
+
# via
|
126 |
+
# -r requirements.in
|
127 |
+
# gradio
|
128 |
+
# matplotlib
|
129 |
+
# pandas
|
130 |
+
# pytorch-lightning
|
131 |
+
# tensorboard
|
132 |
+
# torchmetrics
|
133 |
+
# torchvision
|
134 |
+
# transformers
|
135 |
+
oauthlib==3.2.0
|
136 |
+
# via requests-oauthlib
|
137 |
+
orjson==3.7.8
|
138 |
+
# via gradio
|
139 |
+
packaging==21.3
|
140 |
+
# via
|
141 |
+
# huggingface-hub
|
142 |
+
# matplotlib
|
143 |
+
# pytorch-lightning
|
144 |
+
# torchmetrics
|
145 |
+
# transformers
|
146 |
+
pandas==1.4.3
|
147 |
+
# via gradio
|
148 |
+
paramiko==2.11.0
|
149 |
+
# via gradio
|
150 |
+
pillow==9.2.0
|
151 |
+
# via
|
152 |
+
# gradio
|
153 |
+
# matplotlib
|
154 |
+
# torchvision
|
155 |
+
protobuf==3.19.4
|
156 |
+
# via
|
157 |
+
# pytorch-lightning
|
158 |
+
# tensorboard
|
159 |
+
pyasn1==0.4.8
|
160 |
+
# via
|
161 |
+
# pyasn1-modules
|
162 |
+
# rsa
|
163 |
+
pyasn1-modules==0.2.8
|
164 |
+
# via google-auth
|
165 |
+
pycparser==2.21
|
166 |
+
# via cffi
|
167 |
+
pycryptodome==3.15.0
|
168 |
+
# via gradio
|
169 |
+
pydantic==1.9.1
|
170 |
+
# via
|
171 |
+
# fastapi
|
172 |
+
# gradio
|
173 |
+
pydeprecate==0.3.2
|
174 |
+
# via pytorch-lightning
|
175 |
+
pydub==0.25.1
|
176 |
+
# via gradio
|
177 |
+
pynacl==1.5.0
|
178 |
+
# via paramiko
|
179 |
+
pyparsing==3.0.9
|
180 |
+
# via
|
181 |
+
# matplotlib
|
182 |
+
# packaging
|
183 |
+
python-dateutil==2.8.2
|
184 |
+
# via
|
185 |
+
# analytics-python
|
186 |
+
# matplotlib
|
187 |
+
# pandas
|
188 |
+
python-multipart==0.0.5
|
189 |
+
# via gradio
|
190 |
+
pytorch-lightning==1.6.5
|
191 |
+
# via -r requirements.in
|
192 |
+
pytz==2022.1
|
193 |
+
# via pandas
|
194 |
+
pyyaml==6.0
|
195 |
+
# via
|
196 |
+
# huggingface-hub
|
197 |
+
# pytorch-lightning
|
198 |
+
# transformers
|
199 |
+
regex==2022.7.9
|
200 |
+
# via transformers
|
201 |
+
requests==2.28.1
|
202 |
+
# via
|
203 |
+
# analytics-python
|
204 |
+
# fsspec
|
205 |
+
# gradio
|
206 |
+
# huggingface-hub
|
207 |
+
# requests-oauthlib
|
208 |
+
# tensorboard
|
209 |
+
# torchvision
|
210 |
+
# transformers
|
211 |
+
requests-oauthlib==1.3.1
|
212 |
+
# via google-auth-oauthlib
|
213 |
+
rfc3986[idna2008]==1.5.0
|
214 |
+
# via httpx
|
215 |
+
rsa==4.9
|
216 |
+
# via google-auth
|
217 |
+
six==1.16.0
|
218 |
+
# via
|
219 |
+
# analytics-python
|
220 |
+
# google-auth
|
221 |
+
# grpcio
|
222 |
+
# paramiko
|
223 |
+
# python-dateutil
|
224 |
+
# python-multipart
|
225 |
+
sniffio==1.2.0
|
226 |
+
# via
|
227 |
+
# anyio
|
228 |
+
# httpcore
|
229 |
+
# httpx
|
230 |
+
starlette==0.19.1
|
231 |
+
# via fastapi
|
232 |
+
tensorboard==2.9.1
|
233 |
+
# via pytorch-lightning
|
234 |
+
tensorboard-data-server==0.6.1
|
235 |
+
# via tensorboard
|
236 |
+
tensorboard-plugin-wit==1.8.1
|
237 |
+
# via tensorboard
|
238 |
+
tokenizers==0.12.1
|
239 |
+
# via transformers
|
240 |
+
torch==1.12.0+cu116
|
241 |
+
# via
|
242 |
+
# -r requirements.in
|
243 |
+
# pytorch-lightning
|
244 |
+
# torchaudio
|
245 |
+
# torchmetrics
|
246 |
+
# torchvision
|
247 |
+
torchaudio==0.12.0+cu116
|
248 |
+
# via -r requirements.in
|
249 |
+
torchmetrics==0.9.2
|
250 |
+
# via pytorch-lightning
|
251 |
+
torchvision==0.13.0+cu116
|
252 |
+
# via -r requirements.in
|
253 |
+
tqdm==4.64.0
|
254 |
+
# via
|
255 |
+
# huggingface-hub
|
256 |
+
# pytorch-lightning
|
257 |
+
# transformers
|
258 |
+
transformers==4.20.1
|
259 |
+
# via -r requirements.in
|
260 |
+
typing-extensions==4.3.0
|
261 |
+
# via
|
262 |
+
# huggingface-hub
|
263 |
+
# pydantic
|
264 |
+
# pytorch-lightning
|
265 |
+
# starlette
|
266 |
+
# torch
|
267 |
+
# torchvision
|
268 |
+
uc-micro-py==1.0.1
|
269 |
+
# via linkify-it-py
|
270 |
+
urllib3==1.26.10
|
271 |
+
# via requests
|
272 |
+
uvicorn==0.18.2
|
273 |
+
# via gradio
|
274 |
+
werkzeug==2.1.2
|
275 |
+
# via tensorboard
|
276 |
+
wheel==0.37.1
|
277 |
+
# via tensorboard
|
278 |
+
yarl==1.7.2
|
279 |
+
# via aiohttp
|
280 |
+
zipp==3.8.1
|
281 |
+
# via importlib-metadata
|
282 |
+
|
283 |
+
# The following packages are considered to be unsafe in a requirements file:
|
284 |
+
# setuptools
|
src/app.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from string import punctuation
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
from transformers import AutomaticSpeechRecognitionPipeline
|
5 |
+
from deepmultilingualpunctuation import PunctuationModel
|
6 |
+
|
7 |
+
puntuation_model = PunctuationModel()
|
8 |
+
# capitalization_model = ("KES/caribe-capitalise")
|
9 |
+
# text = "My name is Clara and I live in Berkeley California Ist das eine Frage Frau Müller"
|
10 |
+
# print(result)
|
11 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
12 |
+
|
13 |
+
capitalise_tokenizer = AutoTokenizer.from_pretrained("KES/caribe-capitalise")
|
14 |
+
capitalise_model = AutoModelForSeq2SeqLM.from_pretrained("KES/caribe-capitalise")
|
15 |
+
|
16 |
+
|
17 |
+
pipe = pipeline(
|
18 |
+
model="facebook/wav2vec2-large-960h",
|
19 |
+
chunk_length_s=180,
|
20 |
+
stride_length_s=30,
|
21 |
+
device=0)
|
22 |
+
|
23 |
+
def translate(audio_file):
|
24 |
+
x = pipe(audio_file)
|
25 |
+
text = x['text']
|
26 |
+
return text
|
27 |
+
|
28 |
+
def punctuation(text):
|
29 |
+
punctuation = puntuation_model.restore_punctuation(text)
|
30 |
+
return punctuation
|
31 |
+
|
32 |
+
def capitalise(text):
|
33 |
+
text = text.lower()
|
34 |
+
inputs = capitalise_tokenizer("text:"+text, truncation=True, return_tensors='pt')
|
35 |
+
# print(capitalization)
|
36 |
+
output = capitalise_model.generate(inputs['input_ids'], num_beams=4, max_length=512, early_stopping=True)
|
37 |
+
capitalised_text = capitalise_tokenizer.batch_decode(output, skip_special_tokens=True)
|
38 |
+
|
39 |
+
result = ("".join(capitalised_text))
|
40 |
+
|
41 |
+
return result
|
42 |
+
|
43 |
+
def all(file):
|
44 |
+
trans_text = translate(file).lower()
|
45 |
+
punct_text = punctuation(trans_text)
|
46 |
+
cap_text = capitalise(punct_text)
|
47 |
+
return trans_text, punct_text, cap_text
|
48 |
+
|
49 |
+
input = gr.Audio(type="filepath")
|
50 |
+
live_in = gr.Audio(type="filepath", source="microphone")
|
51 |
+
# options = gr.CheckboxGroup(
|
52 |
+
# options=["text", "punctuation", "capitalisation"],
|
53 |
+
# )
|
54 |
+
raw_output = gr.Text(label="Raw Output")
|
55 |
+
puncuation_output = gr.Text(label="Punctuation Output")
|
56 |
+
capitalization_output = gr.Text(label="Capitalization Output")
|
57 |
+
|
58 |
+
translater = gr.Interface(
|
59 |
+
fn=translate,
|
60 |
+
inputs=input,
|
61 |
+
outputs=[raw_output])
|
62 |
+
|
63 |
+
punctuation = gr.Interface(
|
64 |
+
fn=punctuation,
|
65 |
+
inputs=raw_output,
|
66 |
+
outputs=[puncuation_output])
|
67 |
+
|
68 |
+
capitalization = gr.Interface(
|
69 |
+
fn=capitalise,
|
70 |
+
inputs=puncuation_output,
|
71 |
+
outputs=[capitalization_output])
|
72 |
+
|
73 |
+
|
74 |
+
|
75 |
+
# gr.Series(translater, punctuation, capitalization).launch(share=True)
|
76 |
+
live_demo = gr.Interface(
|
77 |
+
fn=all,
|
78 |
+
inputs=live_in,
|
79 |
+
outputs=[raw_output, puncuation_output, capitalization_output])
|
80 |
+
demo = gr.Interface(
|
81 |
+
fn=all,
|
82 |
+
inputs=input,
|
83 |
+
outputs=[raw_output, puncuation_output, capitalization_output])
|
84 |
+
|
85 |
+
# demo.launch(share=True)
|
86 |
+
gr.TabbedInterface([demo, live_demo], tab_names=["Upload File", "Record Self"]).launch(share=True)
|
src/requirements.in
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
pip-tools
|
2 |
+
|
3 |
+
torch
|
4 |
+
torchvision
|
5 |
+
torchaudio
|
6 |
+
--extra-index-url https://download.pytorch.org/whl/cu116
|
7 |
+
|
8 |
+
pytorch-lightning
|
9 |
+
transformers
|
10 |
+
matplotlib
|
11 |
+
seaborn
|
12 |
+
numpy
|
13 |
+
pandas
|
14 |
+
icecream
|
15 |
+
jupyter
|
16 |
+
gradio
|
src/requirements.txt
ADDED
@@ -0,0 +1,420 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# This file is autogenerated by pip-compile with python 3.8
|
3 |
+
# To update, run:
|
4 |
+
#
|
5 |
+
# pip-compile
|
6 |
+
#
|
7 |
+
--extra-index-url https://download.pytorch.org/whl/cu116
|
8 |
+
|
9 |
+
absl-py==1.2.0
|
10 |
+
# via tensorboard
|
11 |
+
aiohttp==3.8.1
|
12 |
+
# via fsspec
|
13 |
+
aiosignal==1.2.0
|
14 |
+
# via aiohttp
|
15 |
+
argon2-cffi==21.3.0
|
16 |
+
# via notebook
|
17 |
+
argon2-cffi-bindings==21.2.0
|
18 |
+
# via argon2-cffi
|
19 |
+
asttokens==2.0.5
|
20 |
+
# via
|
21 |
+
# icecream
|
22 |
+
# stack-data
|
23 |
+
async-timeout==4.0.2
|
24 |
+
# via aiohttp
|
25 |
+
attrs==21.4.0
|
26 |
+
# via
|
27 |
+
# aiohttp
|
28 |
+
# jsonschema
|
29 |
+
backcall==0.2.0
|
30 |
+
# via ipython
|
31 |
+
beautifulsoup4==4.11.1
|
32 |
+
# via nbconvert
|
33 |
+
bleach==5.0.1
|
34 |
+
# via nbconvert
|
35 |
+
build==0.8.0
|
36 |
+
# via pip-tools
|
37 |
+
cachetools==5.2.0
|
38 |
+
# via google-auth
|
39 |
+
certifi==2022.6.15
|
40 |
+
# via requests
|
41 |
+
cffi==1.15.1
|
42 |
+
# via argon2-cffi-bindings
|
43 |
+
charset-normalizer==2.1.0
|
44 |
+
# via
|
45 |
+
# aiohttp
|
46 |
+
# requests
|
47 |
+
click==8.1.3
|
48 |
+
# via pip-tools
|
49 |
+
colorama==0.4.5
|
50 |
+
# via icecream
|
51 |
+
cycler==0.11.0
|
52 |
+
# via matplotlib
|
53 |
+
debugpy==1.6.2
|
54 |
+
# via ipykernel
|
55 |
+
decorator==5.1.1
|
56 |
+
# via ipython
|
57 |
+
defusedxml==0.7.1
|
58 |
+
# via nbconvert
|
59 |
+
entrypoints==0.4
|
60 |
+
# via
|
61 |
+
# jupyter-client
|
62 |
+
# nbconvert
|
63 |
+
executing==0.8.3
|
64 |
+
# via
|
65 |
+
# icecream
|
66 |
+
# stack-data
|
67 |
+
fastjsonschema==2.16.1
|
68 |
+
# via nbformat
|
69 |
+
filelock==3.7.1
|
70 |
+
# via
|
71 |
+
# huggingface-hub
|
72 |
+
# transformers
|
73 |
+
fonttools==4.34.4
|
74 |
+
# via matplotlib
|
75 |
+
frozenlist==1.3.0
|
76 |
+
# via
|
77 |
+
# aiohttp
|
78 |
+
# aiosignal
|
79 |
+
fsspec[http]==2022.5.0
|
80 |
+
# via pytorch-lightning
|
81 |
+
google-auth==2.9.1
|
82 |
+
# via
|
83 |
+
# google-auth-oauthlib
|
84 |
+
# tensorboard
|
85 |
+
google-auth-oauthlib==0.4.6
|
86 |
+
# via tensorboard
|
87 |
+
grpcio==1.47.0
|
88 |
+
# via tensorboard
|
89 |
+
huggingface-hub==0.8.1
|
90 |
+
# via transformers
|
91 |
+
icecream==2.1.3
|
92 |
+
# via -r requirements.in
|
93 |
+
idna==3.3
|
94 |
+
# via
|
95 |
+
# requests
|
96 |
+
# yarl
|
97 |
+
importlib-metadata==4.12.0
|
98 |
+
# via markdown
|
99 |
+
importlib-resources==5.9.0
|
100 |
+
# via jsonschema
|
101 |
+
ipykernel==6.15.1
|
102 |
+
# via
|
103 |
+
# ipywidgets
|
104 |
+
# jupyter
|
105 |
+
# jupyter-console
|
106 |
+
# notebook
|
107 |
+
# qtconsole
|
108 |
+
ipython==8.4.0
|
109 |
+
# via
|
110 |
+
# ipykernel
|
111 |
+
# ipywidgets
|
112 |
+
# jupyter-console
|
113 |
+
ipython-genutils==0.2.0
|
114 |
+
# via
|
115 |
+
# ipywidgets
|
116 |
+
# notebook
|
117 |
+
# qtconsole
|
118 |
+
ipywidgets==7.7.1
|
119 |
+
# via jupyter
|
120 |
+
jedi==0.18.1
|
121 |
+
# via ipython
|
122 |
+
jinja2==3.1.2
|
123 |
+
# via
|
124 |
+
# nbconvert
|
125 |
+
# notebook
|
126 |
+
jsonschema==4.7.2
|
127 |
+
# via nbformat
|
128 |
+
jupyter==1.0.0
|
129 |
+
# via -r requirements.in
|
130 |
+
jupyter-client==7.3.4
|
131 |
+
# via
|
132 |
+
# ipykernel
|
133 |
+
# jupyter-console
|
134 |
+
# nbclient
|
135 |
+
# notebook
|
136 |
+
# qtconsole
|
137 |
+
jupyter-console==6.4.4
|
138 |
+
# via jupyter
|
139 |
+
jupyter-core==4.11.1
|
140 |
+
# via
|
141 |
+
# jupyter-client
|
142 |
+
# nbconvert
|
143 |
+
# nbformat
|
144 |
+
# notebook
|
145 |
+
# qtconsole
|
146 |
+
jupyterlab-pygments==0.2.2
|
147 |
+
# via nbconvert
|
148 |
+
jupyterlab-widgets==1.1.1
|
149 |
+
# via ipywidgets
|
150 |
+
kiwisolver==1.4.4
|
151 |
+
# via matplotlib
|
152 |
+
markdown==3.4.1
|
153 |
+
# via tensorboard
|
154 |
+
markupsafe==2.1.1
|
155 |
+
# via
|
156 |
+
# jinja2
|
157 |
+
# nbconvert
|
158 |
+
matplotlib==3.5.2
|
159 |
+
# via
|
160 |
+
# -r requirements.in
|
161 |
+
# seaborn
|
162 |
+
matplotlib-inline==0.1.3
|
163 |
+
# via
|
164 |
+
# ipykernel
|
165 |
+
# ipython
|
166 |
+
mistune==0.8.4
|
167 |
+
# via nbconvert
|
168 |
+
multidict==6.0.2
|
169 |
+
# via
|
170 |
+
# aiohttp
|
171 |
+
# yarl
|
172 |
+
nbclient==0.6.6
|
173 |
+
# via nbconvert
|
174 |
+
nbconvert==6.5.0
|
175 |
+
# via
|
176 |
+
# jupyter
|
177 |
+
# notebook
|
178 |
+
nbformat==5.4.0
|
179 |
+
# via
|
180 |
+
# nbclient
|
181 |
+
# nbconvert
|
182 |
+
# notebook
|
183 |
+
nest-asyncio==1.5.5
|
184 |
+
# via
|
185 |
+
# ipykernel
|
186 |
+
# jupyter-client
|
187 |
+
# nbclient
|
188 |
+
# notebook
|
189 |
+
notebook==6.4.12
|
190 |
+
# via
|
191 |
+
# jupyter
|
192 |
+
# widgetsnbextension
|
193 |
+
numpy==1.23.1
|
194 |
+
# via
|
195 |
+
# -r requirements.in
|
196 |
+
# matplotlib
|
197 |
+
# pandas
|
198 |
+
# pytorch-lightning
|
199 |
+
# scipy
|
200 |
+
# seaborn
|
201 |
+
# tensorboard
|
202 |
+
# torchmetrics
|
203 |
+
# torchvision
|
204 |
+
# transformers
|
205 |
+
oauthlib==3.2.0
|
206 |
+
# via requests-oauthlib
|
207 |
+
packaging==21.3
|
208 |
+
# via
|
209 |
+
# build
|
210 |
+
# huggingface-hub
|
211 |
+
# ipykernel
|
212 |
+
# matplotlib
|
213 |
+
# nbconvert
|
214 |
+
# pytorch-lightning
|
215 |
+
# qtpy
|
216 |
+
# torchmetrics
|
217 |
+
# transformers
|
218 |
+
pandas==1.4.3
|
219 |
+
# via
|
220 |
+
# -r requirements.in
|
221 |
+
# seaborn
|
222 |
+
pandocfilters==1.5.0
|
223 |
+
# via nbconvert
|
224 |
+
parso==0.8.3
|
225 |
+
# via jedi
|
226 |
+
pep517==0.12.0
|
227 |
+
# via build
|
228 |
+
pexpect==4.8.0
|
229 |
+
# via ipython
|
230 |
+
pickleshare==0.7.5
|
231 |
+
# via ipython
|
232 |
+
pillow==9.2.0
|
233 |
+
# via
|
234 |
+
# matplotlib
|
235 |
+
# torchvision
|
236 |
+
pip-tools==6.8.0
|
237 |
+
# via -r requirements.in
|
238 |
+
prometheus-client==0.14.1
|
239 |
+
# via notebook
|
240 |
+
prompt-toolkit==3.0.30
|
241 |
+
# via
|
242 |
+
# ipython
|
243 |
+
# jupyter-console
|
244 |
+
protobuf==3.19.4
|
245 |
+
# via
|
246 |
+
# pytorch-lightning
|
247 |
+
# tensorboard
|
248 |
+
psutil==5.9.1
|
249 |
+
# via ipykernel
|
250 |
+
ptyprocess==0.7.0
|
251 |
+
# via
|
252 |
+
# pexpect
|
253 |
+
# terminado
|
254 |
+
pure-eval==0.2.2
|
255 |
+
# via stack-data
|
256 |
+
pyasn1==0.4.8
|
257 |
+
# via
|
258 |
+
# pyasn1-modules
|
259 |
+
# rsa
|
260 |
+
pyasn1-modules==0.2.8
|
261 |
+
# via google-auth
|
262 |
+
pycparser==2.21
|
263 |
+
# via cffi
|
264 |
+
pydeprecate==0.3.2
|
265 |
+
# via pytorch-lightning
|
266 |
+
pygments==2.12.0
|
267 |
+
# via
|
268 |
+
# icecream
|
269 |
+
# ipython
|
270 |
+
# jupyter-console
|
271 |
+
# nbconvert
|
272 |
+
# qtconsole
|
273 |
+
pyparsing==3.0.9
|
274 |
+
# via
|
275 |
+
# matplotlib
|
276 |
+
# packaging
|
277 |
+
pyrsistent==0.18.1
|
278 |
+
# via jsonschema
|
279 |
+
python-dateutil==2.8.2
|
280 |
+
# via
|
281 |
+
# jupyter-client
|
282 |
+
# matplotlib
|
283 |
+
# pandas
|
284 |
+
pytorch-lightning==1.6.5
|
285 |
+
# via -r requirements.in
|
286 |
+
pytz==2022.1
|
287 |
+
# via pandas
|
288 |
+
pyyaml==6.0
|
289 |
+
# via
|
290 |
+
# huggingface-hub
|
291 |
+
# pytorch-lightning
|
292 |
+
# transformers
|
293 |
+
pyzmq==23.2.0
|
294 |
+
# via
|
295 |
+
# ipykernel
|
296 |
+
# jupyter-client
|
297 |
+
# notebook
|
298 |
+
# qtconsole
|
299 |
+
qtconsole==5.3.1
|
300 |
+
# via jupyter
|
301 |
+
qtpy==2.1.0
|
302 |
+
# via qtconsole
|
303 |
+
regex==2022.7.9
|
304 |
+
# via transformers
|
305 |
+
requests==2.28.1
|
306 |
+
# via
|
307 |
+
# fsspec
|
308 |
+
# huggingface-hub
|
309 |
+
# requests-oauthlib
|
310 |
+
# tensorboard
|
311 |
+
# torchvision
|
312 |
+
# transformers
|
313 |
+
requests-oauthlib==1.3.1
|
314 |
+
# via google-auth-oauthlib
|
315 |
+
rsa==4.9
|
316 |
+
# via google-auth
|
317 |
+
scipy==1.8.1
|
318 |
+
# via seaborn
|
319 |
+
seaborn==0.11.2
|
320 |
+
# via -r requirements.in
|
321 |
+
send2trash==1.8.0
|
322 |
+
# via notebook
|
323 |
+
six==1.16.0
|
324 |
+
# via
|
325 |
+
# asttokens
|
326 |
+
# bleach
|
327 |
+
# google-auth
|
328 |
+
# grpcio
|
329 |
+
# python-dateutil
|
330 |
+
soupsieve==2.3.2.post1
|
331 |
+
# via beautifulsoup4
|
332 |
+
stack-data==0.3.0
|
333 |
+
# via ipython
|
334 |
+
tensorboard==2.9.1
|
335 |
+
# via pytorch-lightning
|
336 |
+
tensorboard-data-server==0.6.1
|
337 |
+
# via tensorboard
|
338 |
+
tensorboard-plugin-wit==1.8.1
|
339 |
+
# via tensorboard
|
340 |
+
terminado==0.15.0
|
341 |
+
# via notebook
|
342 |
+
tinycss2==1.1.1
|
343 |
+
# via nbconvert
|
344 |
+
tokenizers==0.12.1
|
345 |
+
# via transformers
|
346 |
+
tomli==2.0.1
|
347 |
+
# via
|
348 |
+
# build
|
349 |
+
# pep517
|
350 |
+
torch==1.12.0+cu116
|
351 |
+
# via
|
352 |
+
# -r requirements.in
|
353 |
+
# pytorch-lightning
|
354 |
+
# torchaudio
|
355 |
+
# torchmetrics
|
356 |
+
# torchvision
|
357 |
+
torchaudio==0.12.0+cu116
|
358 |
+
# via -r requirements.in
|
359 |
+
torchmetrics==0.9.2
|
360 |
+
# via pytorch-lightning
|
361 |
+
torchvision==0.13.0+cu116
|
362 |
+
# via -r requirements.in
|
363 |
+
tornado==6.2
|
364 |
+
# via
|
365 |
+
# ipykernel
|
366 |
+
# jupyter-client
|
367 |
+
# notebook
|
368 |
+
# terminado
|
369 |
+
tqdm==4.64.0
|
370 |
+
# via
|
371 |
+
# huggingface-hub
|
372 |
+
# pytorch-lightning
|
373 |
+
# transformers
|
374 |
+
traitlets==5.3.0
|
375 |
+
# via
|
376 |
+
# ipykernel
|
377 |
+
# ipython
|
378 |
+
# ipywidgets
|
379 |
+
# jupyter-client
|
380 |
+
# jupyter-core
|
381 |
+
# matplotlib-inline
|
382 |
+
# nbclient
|
383 |
+
# nbconvert
|
384 |
+
# nbformat
|
385 |
+
# notebook
|
386 |
+
# qtconsole
|
387 |
+
transformers==4.20.1
|
388 |
+
# via -r requirements.in
|
389 |
+
typing-extensions==4.3.0
|
390 |
+
# via
|
391 |
+
# huggingface-hub
|
392 |
+
# pytorch-lightning
|
393 |
+
# torch
|
394 |
+
# torchvision
|
395 |
+
urllib3==1.26.10
|
396 |
+
# via requests
|
397 |
+
wcwidth==0.2.5
|
398 |
+
# via prompt-toolkit
|
399 |
+
webencodings==0.5.1
|
400 |
+
# via
|
401 |
+
# bleach
|
402 |
+
# tinycss2
|
403 |
+
werkzeug==2.1.2
|
404 |
+
# via tensorboard
|
405 |
+
wheel==0.37.1
|
406 |
+
# via
|
407 |
+
# pip-tools
|
408 |
+
# tensorboard
|
409 |
+
widgetsnbextension==3.6.1
|
410 |
+
# via ipywidgets
|
411 |
+
yarl==1.7.2
|
412 |
+
# via aiohttp
|
413 |
+
zipp==3.8.1
|
414 |
+
# via
|
415 |
+
# importlib-metadata
|
416 |
+
# importlib-resources
|
417 |
+
|
418 |
+
# The following packages are considered to be unsafe in a requirements file:
|
419 |
+
# pip
|
420 |
+
# setuptools
|