-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (28 loc) · 844 Bytes
/
app.py
File metadata and controls
38 lines (28 loc) · 844 Bytes
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
31
32
33
34
35
36
37
38
import os
import json
from flask import Flask, request, redirect
from inference import Inference
import ast
import librosa
from pathlib import Path
from werkzeug import secure_filename
inference = Inference()
app = Flask(__name__)
app.run()
uploads_dir = Path(app.instance_path)/'uploads'
uploads_dir.mkdir(parents=True, exists_ok=True)
@app.route("/")
def hello_world():
return {"Health": "Good"}
@app.route("/test", methods=["GET"])
def test():
return redirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
# client sends bytes to backend
@app.route("/send_recording", methods=["POST"])
def send_recording():
recording = request.files['file']
path = uploads_dir/secure_filename(recording.filename)
recording.save(path)
audio, _ = librosa.load(path, sr=125)
res = inference.predict(audio)
return res