38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
import sys
|
|
import time
|
|
import requests
|
|
import os
|
|
import os.path
|
|
import json
|
|
from datetime import datetime
|
|
|
|
|
|
def main():
|
|
|
|
sleep_time = int(sys.argv[1])
|
|
|
|
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 sleep_time > 0:
|
|
time.sleep(sleep_time)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|