Miroga64 commited on
Commit ·
5edbf12
1
Parent(s): 34837f2
Add application file
Browse files- Dockerfile +9 -0
- main.py +41 -0
- requirements.txt +145 -0
Dockerfile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.8
|
| 2 |
+
WORKDIR /code
|
| 3 |
+
ENV DEBIAN_FRONTEND noninteractive
|
| 4 |
+
COPY requirements.txt requirements.txt
|
| 5 |
+
RUN apt-get update -y && apt install python3-pip -y
|
| 6 |
+
RUN pip install -r requirements.txt
|
| 7 |
+
RUN apt-get install libsndfile1-dev -y
|
| 8 |
+
COPY . .
|
| 9 |
+
CMD ["python3", "main.py"]
|
main.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request
|
| 2 |
+
from flask_restful import Api, Resource
|
| 3 |
+
from flask_cors import CORS
|
| 4 |
+
from waitress import serve
|
| 5 |
+
import whisper
|
| 6 |
+
import librosa
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
app = Flask(__name__)
|
| 11 |
+
CORS(app)
|
| 12 |
+
api = Api()
|
| 13 |
+
|
| 14 |
+
class Main(Resource):
|
| 15 |
+
def post(self):
|
| 16 |
+
print(request)
|
| 17 |
+
file = request.files["file"]
|
| 18 |
+
if file:
|
| 19 |
+
print(file)
|
| 20 |
+
|
| 21 |
+
audio, sr = librosa.load(file.stream)
|
| 22 |
+
audio_array = np.array(audio, dtype=np.float32)
|
| 23 |
+
model = whisper.load_model("small")
|
| 24 |
+
result = model.transcribe(audio_array, fp16=False)
|
| 25 |
+
captions = [[(int)(caption["start"] * 1000), (int)(caption["end"] * 1000), caption["text"]] for caption in
|
| 26 |
+
result['segments']]
|
| 27 |
+
|
| 28 |
+
print(f'Отвечаю: {captions}')
|
| 29 |
+
|
| 30 |
+
return {'status': 'ok', 'captions': captions}
|
| 31 |
+
|
| 32 |
+
def get(self):
|
| 33 |
+
return {'status': 'ok', 'type': 'get'}
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
api.add_resource(Main, "/sendfile/")
|
| 37 |
+
api.init_app(app)
|
| 38 |
+
|
| 39 |
+
if __name__ == "__main__":
|
| 40 |
+
# serve(app, port=5000, host="0.0.0.0")
|
| 41 |
+
app.run(debug=True, port=7860, host="0.0.0.0")
|
requirements.txt
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
absl-py==1.4.0
|
| 2 |
+
aiohttp==3.8.3
|
| 3 |
+
aiosignal==1.3.1
|
| 4 |
+
alembic==1.9.3
|
| 5 |
+
aniso8601==9.0.1
|
| 6 |
+
antlr4-python3-runtime==4.9.3
|
| 7 |
+
appdirs==1.4.4
|
| 8 |
+
asteroid-filterbanks==0.4.0
|
| 9 |
+
async-timeout==4.0.2
|
| 10 |
+
attrs==22.2.0
|
| 11 |
+
audioread==3.0.0
|
| 12 |
+
backports.cached-property==1.0.2
|
| 13 |
+
Brotli==1.0.9
|
| 14 |
+
cachetools==5.3.0
|
| 15 |
+
certifi==2022.12.7
|
| 16 |
+
cffi==1.15.1
|
| 17 |
+
charset-normalizer==2.1.1
|
| 18 |
+
click==8.1.3
|
| 19 |
+
cmaes==0.9.1
|
| 20 |
+
colorama==0.4.6
|
| 21 |
+
colorlog==6.7.0
|
| 22 |
+
commonmark==0.9.1
|
| 23 |
+
contourpy==1.0.7
|
| 24 |
+
cycler==0.11.0
|
| 25 |
+
decorator==5.1.1
|
| 26 |
+
docopt==0.6.2
|
| 27 |
+
einops==0.3.2
|
| 28 |
+
ffmpeg-python==0.2.0
|
| 29 |
+
filelock==3.9.0
|
| 30 |
+
Flask==2.2.2
|
| 31 |
+
Flask-Cors==3.0.10
|
| 32 |
+
Flask-RESTful==0.3.9
|
| 33 |
+
fonttools==4.38.0
|
| 34 |
+
frozenlist==1.3.3
|
| 35 |
+
fsspec==2023.1.0
|
| 36 |
+
future==0.18.3
|
| 37 |
+
google-auth==2.16.0
|
| 38 |
+
google-auth-oauthlib==0.4.6
|
| 39 |
+
greenlet==2.0.2
|
| 40 |
+
grpcio==1.51.1
|
| 41 |
+
hmmlearn==0.2.8
|
| 42 |
+
huggingface-hub==0.12.0
|
| 43 |
+
HyperPyYAML==1.1.0
|
| 44 |
+
idna==3.4
|
| 45 |
+
importlib-metadata==6.0.0
|
| 46 |
+
importlib-resources==5.10.2
|
| 47 |
+
install==1.3.5
|
| 48 |
+
itsdangerous==2.1.2
|
| 49 |
+
Jinja2==3.1.2
|
| 50 |
+
joblib==1.2.0
|
| 51 |
+
julius==0.2.7
|
| 52 |
+
kiwisolver==1.4.4
|
| 53 |
+
lazy_loader==0.2
|
| 54 |
+
librosa==0.9.2
|
| 55 |
+
llvmlite==0.39.1
|
| 56 |
+
Mako==1.2.4
|
| 57 |
+
Markdown==3.4.1
|
| 58 |
+
MarkupSafe==2.1.2
|
| 59 |
+
matplotlib==3.6.3
|
| 60 |
+
more-itertools==9.0.0
|
| 61 |
+
mpmath==1.2.1
|
| 62 |
+
msgpack==1.0.5
|
| 63 |
+
multidict==6.0.4
|
| 64 |
+
mutagen==1.46.0
|
| 65 |
+
networkx==2.8.8
|
| 66 |
+
np==1.0.2
|
| 67 |
+
numba==0.56.4
|
| 68 |
+
numpy==1.23.5
|
| 69 |
+
oauthlib==3.2.2
|
| 70 |
+
omegaconf==2.3.0
|
| 71 |
+
openai==0.27.2
|
| 72 |
+
openai-whisper==20230124
|
| 73 |
+
optuna==3.1.0
|
| 74 |
+
packaging==23.0
|
| 75 |
+
pandas==1.5.3
|
| 76 |
+
Pillow==9.4.0
|
| 77 |
+
pooch==1.6.0
|
| 78 |
+
primePy==1.3
|
| 79 |
+
protobuf==3.20.1
|
| 80 |
+
pyannote.audio==2.1.1
|
| 81 |
+
pyannote.core==4.5
|
| 82 |
+
pyannote.database==4.1.3
|
| 83 |
+
pyannote.metrics==3.2.1
|
| 84 |
+
pyannote.pipeline==2.3
|
| 85 |
+
pyasn1==0.4.8
|
| 86 |
+
pyasn1-modules==0.2.8
|
| 87 |
+
pycparser==2.21
|
| 88 |
+
pycryptodomex==3.17
|
| 89 |
+
pyDeprecate==0.3.2
|
| 90 |
+
pydub==0.25.1
|
| 91 |
+
Pygments==2.14.0
|
| 92 |
+
pyparsing==3.0.9
|
| 93 |
+
python-dateutil==2.8.2
|
| 94 |
+
pytorch-lightning==1.6.5
|
| 95 |
+
pytorch-metric-learning==1.7.3
|
| 96 |
+
pytz==2022.7.1
|
| 97 |
+
PyYAML==6.0
|
| 98 |
+
regex==2022.10.31
|
| 99 |
+
requests==2.28.2
|
| 100 |
+
requests-oauthlib==1.3.1
|
| 101 |
+
resampy==0.4.2
|
| 102 |
+
rich==12.6.0
|
| 103 |
+
rsa==4.9
|
| 104 |
+
ruamel.yaml==0.17.21
|
| 105 |
+
ruamel.yaml.clib==0.2.7
|
| 106 |
+
scikit-learn==1.2.1
|
| 107 |
+
scipy==1.10.0
|
| 108 |
+
semver==2.13.0
|
| 109 |
+
sentencepiece==0.1.97
|
| 110 |
+
shellingham==1.5.0.post1
|
| 111 |
+
simplejson==3.18.3
|
| 112 |
+
singledispatchmethod==1.0
|
| 113 |
+
six==1.15.0
|
| 114 |
+
sortedcontainers==2.4.0
|
| 115 |
+
SoundFile==0.10.3.post1
|
| 116 |
+
soxr==0.3.4
|
| 117 |
+
speechbrain==0.5.13
|
| 118 |
+
SQLAlchemy==2.0.2
|
| 119 |
+
srt==3.5.2
|
| 120 |
+
sympy==1.11.1
|
| 121 |
+
tabulate==0.9.0
|
| 122 |
+
tensorboard==2.11.2
|
| 123 |
+
tensorboard-data-server==0.6.1
|
| 124 |
+
tensorboard-plugin-wit==1.8.1
|
| 125 |
+
threadpoolctl==3.1.0
|
| 126 |
+
tiktoken==0.3.2
|
| 127 |
+
tokenizers==0.13.2
|
| 128 |
+
torch==1.13.1
|
| 129 |
+
torch-audiomentations==0.11.0
|
| 130 |
+
torch-pitch-shift==1.2.2
|
| 131 |
+
torchaudio==0.13.1
|
| 132 |
+
torchmetrics==0.11.1
|
| 133 |
+
torchvision==0.14.1
|
| 134 |
+
tqdm==4.64.1
|
| 135 |
+
transformers==4.26.0
|
| 136 |
+
typer==0.7.0
|
| 137 |
+
typing_extensions==4.4.0
|
| 138 |
+
urllib3==1.26.14
|
| 139 |
+
vosk==0.3.44
|
| 140 |
+
waitress==2.1.2
|
| 141 |
+
websockets==10.4
|
| 142 |
+
Werkzeug==2.2.2
|
| 143 |
+
yarl==1.8.2
|
| 144 |
+
yt-dlp==2023.1.6
|
| 145 |
+
zipp==3.12.1
|