Skip to main content

News & Time Bulletin Engine (bulletin-engine.js)

Since 2026-08-11 the station has real top-of-hour radio: a R128-mastered spoken bulletin (station open + Cairo time check → weather → headlines → return to music) generated on demand and scheduled to air hourly. bulletin-engine.js is self-contained (requires paths.js only).

What it generates

OutputFormat
media/news/NEWS_<ts>.mp3~34–37 s Arabic spoken bulletin, Break-tagged
LoudnessTwo-pass EBU R128 → −14 LUFS / −1.5 dBTP (identical to imaging-engine, sits at music loudness)

Bulletin recipe (4 segments)

  1. Station open + Cairo time checktimeCheckArabic(): "إنها الآن الساعة التاسعة مساءً بتوقيت القاهرة" (word-hours + minutes + period صباحاً / ظهراً / مساءً / ليلاً).
  2. Weather — Open-Meteo Cairo (free, no API key): temperature + WMO description + wind.
  3. Headlines — the first 3 lines of E:\radionew\news.txt (editable, one per line, Arabic). "وأبرز العناوين: …".
  4. Return — "الآن عودة للموسيقى".

Each segment is TTS'd separately (edge-tts, ar-EG-ShakirNeural, rate +8%) using -f temp files (never shell args — Arabic/backtick-safe), concatenated with 0.55 s silence, loudnorm pre-pass, then R128 master.

Scheduler wiring (smart-scheduler.js)

  • news is a full imaging category: in decks, categories, imagingCategories, isImaging, and the 10-min ELEMENT_COOLDOWN list.
  • Quality-gate exempt — a 35 s bulletin would fail the 45 s music floor, so news is on the probe-exempt list.
  • NEWS_EVERY cadence slot (~every 20–24 tracks ≈ hourly) forces a news pick in every daypart (deep night included) — same pattern as the AD_EVERY slot.
  • radio-engine.js mediaPaths maps news: media/news.

Server (server.js)

EndpointPurpose
POST /api/bulletin/generateGenerate a bulletin + resync the rotation + push
GET /api/bulletin/statusLatest file, current headlines, live Cairo time-check sentence

scheduleBulletinAutoGen() runs at boot +30 s and every BULLETIN_HOURS (default 1 h, chained setTimeout; 0 disables). MCP tools: generate_bulletin, bulletin_status.

Updating headlines

Edit E:\radionew\news.txt (one headline per line), then POST /api/bulletin/generate — or just wait for the next hourly run (it re-reads the file). All content is Arabic; English listeners get English music around it.

Critical gotcha: SYSTEM-session python

The engine runs as SYSTEM (ServerGuard, session 0) where bare python resolves to the WindowsApps stub → edge-tts spawns fail silently with ✗ TTS failed for segment 0..3 / Done (FAILED: all-tts-failed). PYTHON_BIN must be the absolute C:/Users/omar/AppData/Local/Programs/Python/Python312/python.exe.

Prerequisites

  • pip install edge-tts (edge_tts 7.2.8); endpoint speech.platform.bing.com reachable (HTTP 200).
  • ffmpeg at C:/ffmpeg/bin.

Deployed live 2026-08-11: 37.1 s bulletin, news deck 1, remote m3u head annotate:type=news:NEWS_*.mp3, file size-verified remotely (890591 bytes).

See also