ACRCloud auto-recognition: never block uploads, fall back to fingerprinting
Changes: 1. UI: removed blocking prompt() that asked for artist+title on filename that didn't match 'Artist - Title' pattern. Upload always proceeds. Instead shows yellow warning saying 'server will try to recognize'. 2. Backend: added scripts/acr_recognize.py — extracts 20s audio sample from video (at 15s and 60s offsets for robustness), computes ACRCloud fingerprint via native binary (3KB payload), sends to identify API. 3. Pipeline: process_job() now runs ACR recognition step before analysis IF parsed_artist or parsed_title is missing. Result is saved to job metadata and used for download filename + Scribe/Claude filename hint. 4. Credentials: ACR_HOST + ACR_ACCESS_KEY + ACR_SECRET_KEY env vars added to Coolify (using existing keys from openclaw fb-agent metka). 5. requirements.txt: added pyacrcloud==1.0.11 for native fingerprinting. This unblocks future automation/cron upload pipelines — files don't need to be perfectly named, ACRCloud will identify them automatically. Fallback chain: 1. Filename parsing (Artist - Title.mp4) 2. ACRCloud audio fingerprint (works even for '12345.mp4', 'IMG_001.mp4') 3. If both fail: download filename uses 'reel_<id>.mp4' (still works)
This commit is contained in:
+29
@@ -338,6 +338,35 @@ def process_job(job_id):
|
||||
else:
|
||||
input_path = Path(job["input_path"])
|
||||
|
||||
# ── 1b. Music recognition (ACRCloud) — če nimamo artist+title ─────
|
||||
# Tudi za YouTube jobs lahko naslov ni razviden (npr. iz playliste, "Track 5")
|
||||
if not (job.get("parsed_artist") and job.get("parsed_title")):
|
||||
update_job(job_id, current_step="Avto-prepoznavam pesem (ACRCloud)")
|
||||
try:
|
||||
acr_cmd = [
|
||||
"python3", str(SCRIPTS_DIR / "acr_recognize.py"),
|
||||
str(input_path),
|
||||
]
|
||||
proc = subprocess.run(acr_cmd, capture_output=True, text=True, timeout=120)
|
||||
if proc.returncode == 0 and proc.stdout:
|
||||
data = json.loads(proc.stdout)
|
||||
a, t = data.get("artist"), data.get("title")
|
||||
if a and t:
|
||||
update_job(
|
||||
job_id,
|
||||
parsed_artist=a, parsed_title=t,
|
||||
has_clean_name=True,
|
||||
recognized_via="acrcloud",
|
||||
)
|
||||
job = load_job(job_id)
|
||||
print(f"✅ ACR prepoznal: {a} - {t}", flush=True)
|
||||
else:
|
||||
print(f"⚠️ ACR ni prepoznal pesmi", flush=True)
|
||||
else:
|
||||
print(f"⚠️ ACR exit {proc.returncode}: {proc.stderr[:200]}", flush=True)
|
||||
except Exception as e:
|
||||
print(f"⚠️ ACR error: {e}", flush=True)
|
||||
|
||||
# ── 2. Smart analysis (če auto_chorus) ──────────────────────────
|
||||
if job.get("auto_chorus"):
|
||||
update_job(job_id, current_step="Analiza pesmi (transkript + energija)")
|
||||
|
||||
Reference in New Issue
Block a user