2021-11-24 20:50:26 +01:00
|
|
|
#!/usr/bin/env python3
|
2021-11-24 21:25:55 +01:00
|
|
|
import sys
|
|
|
|
import time
|
2021-11-24 20:50:26 +01:00
|
|
|
import requests
|
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
import json
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-11-24 21:25:55 +01:00
|
|
|
|
|
|
|
sleep_time = int(sys.argv[1])
|
|
|
|
|
2021-11-24 20:50:26 +01:00
|
|
|
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()
|
2021-11-24 21:25:55 +01:00
|
|
|
if sleep_time > 0:
|
|
|
|
time.sleep(sleep_time)
|
2021-11-24 20:50:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|