feat: add advanced tuning, diarization, and LLM support to multi-process engine
This commit is contained in:
+22
-20
@@ -2,6 +2,7 @@ import requests
|
||||
import time
|
||||
import argparse
|
||||
import multiprocessing
|
||||
import sys
|
||||
|
||||
INGEST_URL = "https://emiapi.reynafamily.com/live-captions/ingest"
|
||||
|
||||
@@ -13,37 +14,38 @@ def run_distribution(in_queue, args):
|
||||
payload = in_queue.get()
|
||||
if payload is None: break
|
||||
|
||||
# Draft support
|
||||
if "draft" in payload:
|
||||
draft_text = payload["draft"]
|
||||
sys.stdout.write(f"\r\033[K[DRAFT]: {draft_text}")
|
||||
sys.stdout.flush()
|
||||
if args.ingest:
|
||||
requests.post(INGEST_URL, json={"draft": draft_text}, timeout=2)
|
||||
continue
|
||||
|
||||
# Finalized segment
|
||||
print(f"\n[Final]: {payload.get('original', '')}")
|
||||
for lang in ["es", "fr", "ar", "en"]:
|
||||
if payload.get(lang):
|
||||
print(f"[{lang.upper()}]: {payload[lang]}")
|
||||
|
||||
if args.ingest:
|
||||
delay = 1
|
||||
max_delay = 15
|
||||
success = False
|
||||
|
||||
delay, max_delay, success = 1, 15, False
|
||||
while not success:
|
||||
try:
|
||||
response = requests.post(INGEST_URL, json=payload, timeout=5)
|
||||
if response.status_code == 200:
|
||||
success = True
|
||||
else:
|
||||
print(f"[Distribute Error] {response.status_code}. Retrying in {delay}s...")
|
||||
if response.status_code == 200: success = True
|
||||
else: print(f"[Distribute Error] {response.status_code}. Retrying...")
|
||||
except Exception as e:
|
||||
print(f"[Distribute Error] {e}. Retrying in {delay}s...")
|
||||
print(f"[Distribute Error] {e}. Retrying...")
|
||||
|
||||
if not success:
|
||||
time.sleep(delay)
|
||||
delay = min(delay * 2, max_delay)
|
||||
|
||||
print(f"[Distribute] Sent payload: {list(payload.keys())}")
|
||||
else:
|
||||
print(f"[Distribute] Local display (ingest disabled): {payload}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"[Distribute] Error: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-i", "--ingest", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Dummy queue for testing
|
||||
in_q = multiprocessing.Queue()
|
||||
run_distribution(in_q, args)
|
||||
import multiprocessing
|
||||
run_distribution(multiprocessing.Queue(), argparse.Namespace())
|
||||
|
||||
Reference in New Issue
Block a user