diff --git a/.gitignore b/.gitignore index 2a65b26..d78b9e1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *.log *.db *.conf -configs/* \ No newline at end of file +configs/* +*.json \ No newline at end of file diff --git a/app/node_main.py b/app/node_main.py index 6f6af6b..9e0662d 100644 --- a/app/node_main.py +++ b/app/node_main.py @@ -9,7 +9,6 @@ from internal.logger import create_logger from internal.op25_config_utls import scan_local_library import paho.mqtt.client as mqtt import requests -from google.cloud import storage # Initialize logging LOGGER = create_logger(__name__) @@ -23,7 +22,6 @@ NODE_ID = os.getenv("NODE_ID", "standalone-node") MQTT_BROKER = os.getenv("MQTT_BROKER", None) NODE_LAT = os.getenv("NODE_LAT") NODE_LONG = os.getenv("NODE_LONG") -AUDIO_BUCKET = os.getenv("AUDIO_BUCKET") # Global flag to track MQTT connection state MQTT_CONNECTED = False @@ -246,16 +244,16 @@ async def mqtt_lifecycle_manager(): recorder_proc = None def upload_audio(call_id): - if not AUDIO_BUCKET: return None + if not MQTT_BROKER: return None local_path = f"/calls/{call_id}.mp3" if not os.path.exists(local_path): return None try: - client = storage.Client() - bucket = client.bucket(AUDIO_BUCKET) - blob = bucket.blob(f"audio/{call_id}.mp3") - blob.upload_from_filename(local_path, content_type="audio/mpeg") - return f"gs://{AUDIO_BUCKET}/audio/{call_id}.mp3" + with open(local_path, "rb") as f: + files = {"file": (f"{call_id}.mp3", f, "audio/mpeg")} + response = requests.post(f"{MQTT_BROKER}/upload", files=files, data={"node_id": NODE_ID, "call_id": call_id}, timeout=30) + response.raise_for_status() + return response.json().get("url") except Exception as e: LOGGER.error(f"Upload failed: {e}") return None diff --git a/requirements.txt b/requirements.txt index b6472b2..e49e782 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,4 @@ uvicorn[standard] paho-mqtt pydantic python-multipart -requests -google-cloud-storage \ No newline at end of file +requests \ No newline at end of file