File size: 886 Bytes
f3aa286
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import Flask
from flask_restx import Api, Resource, fields
from werkzeug.datastructures import FileStorage
import wav2vec2 as wave

flask_app = Flask(__name__)
app = Api(app = flask_app,
          version="1.0",
          title="Model deployment test",
          description="Test your models and feel rad")

upload_parser = app.parser()
upload_parser.add_argument('file',
                           location='files',
                           type=FileStorage)


model = app.model('Soundfile',
		  {'name': fields.String(required = True,
					 description="The soudnfile you want to decode",
					 help="File is necessary")})

@app.route('/transcribe', methods=['POST'])
@app.expect(upload_parser)
class Transcribe(Resource):
    def post(self):
        args = upload_parser.parse_args()
        file = args.get('file')
        text = wave.predict(file)
        return text