updated skeleton with true data

This commit is contained in:
2025-12-09 08:40:18 +01:00
parent 61e6644158
commit 8cd91b6f22
27 changed files with 1193 additions and 14 deletions

1
gateway/core/cache.py Normal file
View File

@ -0,0 +1 @@
# optional cache placeholder

1
gateway/core/config.py Normal file
View File

@ -0,0 +1 @@
REDIS_HOST='redis'

View File

@ -0,0 +1 @@
# logging config placeholder

1
gateway/core/models.py Normal file
View File

@ -0,0 +1 @@
# pydantic models placeholder

View File

@ -0,0 +1,25 @@
import redis, uuid, json, time, os
REDIS_HOST = os.environ.get("REDIS_HOST", "redis")
r = redis.Redis(host=REDIS_HOST, port=6379, db=0)
QUEUE="tts_queue"
RESULT="tts_result"
def push_job(data: dict) -> str:
job_id = str(uuid.uuid4())
data["job_id"] = job_id
r.lpush(QUEUE, json.dumps(data))
return job_id
def await_result(job_id: str, timeout=30):
key = f"{RESULT}:{job_id}"
start=time.time()
while time.time()-start < timeout:
data=r.get(key)
if data:
r.delete(key)
obj=json.loads(data)
return bytes.fromhex(obj["audio"]), obj["mime"]
time.sleep(0.1)
raise TimeoutError("Worker antwortet nicht")