call-to-text/storage/exporter.py
ed0ss 7f03949593 Первая версия: транскрипция звонков из Novofon DATA API в Directus
- Клиент Novofon DATA API (JSON-RPC, get.calls_report, чанки по 90 дней)
- faster-whisper (модель turbo) на CUDA с разделением стереоканалов
- Маркировка спикеров: левый канал = caller, правый = callee
- Directus: коллекции calls, calls_74951284933, contacts
- CLI: process, process-file, export, daemon (polling 5 мин)
- Docker Compose для Directus + PostgreSQL
- Архив email-парсинга в old/
2026-06-26 12:44:50 +03:00

24 lines
704 B
Python

import json
from storage.directus import DirectusClient
def export_to_json(filepath: str):
calls = _export_from_directus()
with open(filepath, "w", encoding="utf-8") as f:
json.dump(calls, f, ensure_ascii=False, indent=2, default=str)
def _export_from_directus() -> list[dict]:
try:
dc = DirectusClient()
if not dc.is_available():
return []
all_calls = []
for col in ["calls", "calls_74951284933"]:
resp = dc._client.get(f"/items/{col}")
if resp.status_code == 200:
all_calls.extend(resp.json().get("data", []))
dc.close()
return all_calls
except Exception:
return []