This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
from datetime import datetime
|
||||
import requests
|
||||
from .abcsender import AbcSender
|
||||
from utils import config
|
||||
|
||||
"""
|
||||
Send a sound sample
|
||||
@@ -15,9 +21,22 @@ class SoundSender(AbcSender):
|
||||
"""
|
||||
SoundSender class, responsible for sending sound samples to the cloud.
|
||||
"""
|
||||
def sendvalue(self, value, decision):
|
||||
|
||||
def sendvalue(self, value: str, decision: bool) -> None:
|
||||
"""
|
||||
Send a sound sample to the cloud.
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
if decision:
|
||||
files = {
|
||||
"file": (os.path.basename(value), open(value, 'rb').read(), 'audio/wave',
|
||||
{'Content-length': os.path.getsize(value)}),
|
||||
"description": (
|
||||
None, json.dumps({'date': datetime.now().isoformat(), 'device_id': config.DEVICE_ID}),
|
||||
"application/json")
|
||||
}
|
||||
|
||||
r = requests.post(config.INPUT_SVC_URL, files=files)
|
||||
logging.info("Content: ", r.content)
|
||||
logging.info("Headers:", r.headers)
|
||||
r.raise_for_status()
|
||||
|
||||
Reference in New Issue
Block a user