Added more stuff
This commit is contained in:
parent
2069898190
commit
5294eae48a
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,4 +7,5 @@ __pycache__
|
|||||||
*.log
|
*.log
|
||||||
.idea
|
.idea
|
||||||
*.wav
|
*.wav
|
||||||
big_chop_output/
|
big_chop_output/
|
||||||
|
arrived.txt
|
||||||
|
33
evaluation_server.py
Normal file
33
evaluation_server.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from flask import Flask, request, abort, Response
|
||||||
|
import json
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/', methods=['POST'])
|
||||||
|
def record():
|
||||||
|
if 'file' not in request.files:
|
||||||
|
return abort(400, "no file found")
|
||||||
|
else:
|
||||||
|
soundfile = request.files['file']
|
||||||
|
|
||||||
|
if 'description' not in request.form:
|
||||||
|
return abort(400, "no description found")
|
||||||
|
else:
|
||||||
|
description_raw = request.form.get("description")
|
||||||
|
|
||||||
|
if soundfile.content_type != 'audio/wave':
|
||||||
|
return abort(415, 'Input file not a wave file.')
|
||||||
|
try:
|
||||||
|
desc = json.loads(description_raw)
|
||||||
|
except:
|
||||||
|
return abort(417, 'Input JSON schema invalid')
|
||||||
|
|
||||||
|
with open("arrived.txt", "at") as f:
|
||||||
|
f.write(f"{desc['device_id']}\n")
|
||||||
|
|
||||||
|
return Response(status=200)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='0.0.0.0')
|
30
push_csirip.py
Normal file
30
push_csirip.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
import json
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
for root, _, files in os.walk("big_chop_output/"):
|
||||||
|
for file in files:
|
||||||
|
full_filename = os.path.join(root,file)
|
||||||
|
print(".", end='', flush=True)
|
||||||
|
description = {"device_id": int(os.path.splitext(file)[0]), "date": datetime.now().isoformat()}
|
||||||
|
files = {
|
||||||
|
"file": (
|
||||||
|
os.path.basename(file),
|
||||||
|
open(full_filename, 'rb').read(),
|
||||||
|
'audio/wave',
|
||||||
|
{'Content-length': os.path.getsize(full_filename)}
|
||||||
|
),
|
||||||
|
"description": (None, json.dumps(description), "application/json")
|
||||||
|
}
|
||||||
|
|
||||||
|
r = requests.post("http://127.0.0.1:8000/filter", files=files)
|
||||||
|
r.raise_for_status()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
requests
|
||||||
|
flask
|
Loading…
Reference in New Issue
Block a user