MartaKozina
commited on
Commit
·
9942820
1
Parent(s):
33f732b
Upload main.py
Browse files
main.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask
|
2 |
+
from flask_restx import Api, Resource, fields
|
3 |
+
from werkzeug.datastructures import FileStorage
|
4 |
+
import wav2vec2 as wave
|
5 |
+
|
6 |
+
flask_app = Flask(__name__)
|
7 |
+
app = Api(app = flask_app,
|
8 |
+
version="1.0",
|
9 |
+
title="Model deployment test",
|
10 |
+
description="Test your models and feel rad")
|
11 |
+
|
12 |
+
upload_parser = app.parser()
|
13 |
+
upload_parser.add_argument('file',
|
14 |
+
location='files',
|
15 |
+
type=FileStorage)
|
16 |
+
|
17 |
+
|
18 |
+
model = app.model('Soundfile',
|
19 |
+
{'name': fields.String(required = True,
|
20 |
+
description="The soudnfile you want to decode",
|
21 |
+
help="File is necessary")})
|
22 |
+
|
23 |
+
@app.route('/transcribe', methods=['POST'])
|
24 |
+
@app.expect(upload_parser)
|
25 |
+
class Transcribe(Resource):
|
26 |
+
def post(self):
|
27 |
+
args = upload_parser.parse_args()
|
28 |
+
file = args.get('file')
|
29 |
+
text = wave.predict(file)
|
30 |
+
return text
|