# Cron Job: morning-briefing

**Job ID:** 18c46fde1520
**Run Time:** 2026-05-18 05:45:34
**Schedule:** 0 9 * * *

## Prompt

[IMPORTANT: The user has invoked the "morning-briefing" skill, indicating they want you to follow its instructions. The full skill content is loaded below.]

---
name: morning-briefing
description: "Daily morning voice briefing via Telegram — searches news/weather, cleans text for TTS, delivers audio. Built on Hermes cron + Tavily + MiniMax TTS."
version: 1.0.0
author: Hermes Agent
platforms: [linux]
tags: [cron, telegram, tts, tavily, mini-max, news, voice, briefing]
metadata:
  cron_job_id: "18c46fde1520"
  tavily_key: "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"
  schedule: "0 9 * * *"
  minimax_tts_key_note: "MINIMAX_API_KEY (TTS) is SEPARATE from MINIMAX_CN_API_KEY (chat). Both must be set. The TTS endpoint (speech-02-hd) uses api.minimaxi.com/v1/t2a_v2 and requires MINIMAX_API_KEY. The chat endpoint uses api.minimaxi.com/anthropic with MINIMAX_CN_API_KEY."
---

# Morning Briefing

Daily voice briefing delivered to Telegram at 09:00 BST (16:00 北京).

## Workflow

1. `web_search` — search today's news via Tavily
2. `web_search` — get weather for user's city
3. **Art industry news** — web_search for "艺术行业新闻 中国" (museums, galleries, auctions, cultural heritage, etc.)
4. Compile briefing text in Chinese
5. **Convert all Arabic numerals to Chinese characters** (critical — see Pitfalls)
6. **MiniMax TTS via `text_to_speech` tool** (preferred — best quality, broadcast style)
7. **Playback on local speakers** — set volume to 80%, play via ffplay
8. **Fallback: Local Piper** via `~/bin/tts_briefing.sh` (only if MiniMax fails)
9. Cron auto-delivers to Telegram

## Briefing Template

```
K.W.，早上好！今天是{dates}，{weekday}。

重要新闻：
{n}条新闻，每条一行

艺术动态：
{艺术新闻，1条}

{city}天气预报：{weather}，气温{temp}。

MEDIA:/path/to/audio.ogg
```

## Audio Playback (Local Speakers at 9 AM)

After TTS generation, play the audio on the local machine's speakers at 80% volume:

```bash
# Set system volume to 80% (unmuted)
pactl set-sink-volume alsa_output.pci-0000_00_1f.3.analog-stereo 80%
pactl set-sink-mute alsa_output.pci-0000_00_1f.3.analog-stereo false

# Play audio
ffplay -nodisp -autoexit -volume 80 /home/kuhnn/.hermes/audio_cache/tts_YYYYMMDD_HHMMSS.ogg &
```

**Audio device (ALSA):** `alsa_output.pci-0000_00_1f.3.analog-stereo` — confirm with `pactl list sinks` if different.

## Pitfalls

### TTS reads numbers as digits
MiniMax TTS (and most Chinese TTS) reads `18°C`、`2026年5月18日`、`85%` as individual digits. **ALL numbers must be pre-converted to Chinese characters:**

| Original | For TTS |
|----------|---------|
| 18°C | 十八度 |
| 27°C | 二十七度 |
| 2026年5月18日 | 二零二六年五月十八日 |
| 85% | 百分之八十五 |
| 79年 | 七十九年 |
| 20~32°C | 二十到三十二度 |

Always apply this conversion in the prompt: e.g. `"温度用中文，如'十八到二十七度'"`

## Cron Job Management

```bash
# List jobs
hermes cron list

# Run manually (for testing)
hermes cron run <job_id>

# View output
cat ~/.hermes/cron/output/<job_id>/*.md

# Find latest audio file
find ~/.hermes/audio_cache/ -name "*.ogg" -newer ~/.hermes/cron/output/<job_id>/*.md
```

Current job ID: `18c46fde1520`

## TTS: MiniMax API (Preferred — Best Quality)

MiniMax TTS (speech-02-hd, voice: Chinese_Mandarin_News_Anchor) gives significantly better quality — natural pauses, proper intonation, broadcast style. Use `text_to_speech` tool directly.

**IMPORTANT — Cron environment:** Cron runs in a fresh subprocess without your session's env vars. Before calling `text_to_speech`, the agent MUST load .env:
```bash
export $(grep MINIMAX_API_KEY /home/kuhnn/.hermes/.env | xargs)
```
The `skills: [morning-briefing]` attachment on the cron job ensures the skill is loaded, which triggers the env loading logic. If TTS still fails with "MINIMAX_API_KEY not set", manually add the export step to the cron prompt.

**TTS config (in cron prompt):**
```
使用 text_to_speech 工具（provider: minimax, model: speech-02-hd, voice: Chinese (Mandarin)_News_Anchor）
输出 .ogg 格式文件
在回复末尾写：MEDIA:/home/kuhnn/.hermes/audio_cache/tts_YYYYMMDD_HHMMSS.ogg
```

**Rate limit:** MiniMax 年计划 1500次/5小时。超出后 cron 会静默失败，fallback 到 Piper。

## TTS: Piper (Fallback — Fully Offline)

When MiniMax is unavailable (quota exhausted, network down), fall back to local Piper via `~/bin/tts_briefing.sh`:

```bash
# Generate audio from text
echo "播报文本内容" | ~/bin/tts_briefing.sh --out /home/kuhnn/.hermes/audio_cache/tts_$(date +%Y%m%d_%H%M%S).wav

# Convert to .ogg for Telegram
ffmpeg -i /home/kuhnn/.hermes/audio_cache/tts_YYYYMMDD_HHMMSS.wav \
       -acodec libopus /home/kuhnn/.hermes/audio_cache/tts_YYYYMMDD_HHMMSS.ogg -y

# Deliver: MEDIA:/home/kuhnn/.hermes/audio_cache/tts_YYYYMMDD_HHMMSS.ogg
```

**Piper quality note:** csukuangfj/vits-piper-zh_CN-huayan-medium has mechanical pauses and flat intonation. Acceptable for fallback, not ideal for daily use.

**Piper setup:** `pip install piper-tts` → `~/.local/bin/piper` + model `csukuangfj/vits-piper-zh_CN-huayan-medium` (HuggingFace cache). Use **python3.10** (not 3.11) for huggingface_hub downloads.

## Reference Files

- `references/brief_text_clean.py` — Python TTS text cleaner (numbers→中文, acronyms→full form, punctuation normalization). Derived from OpenClaw's offline TTS pipeline.
- `references/brief_replacements.json` — Acronym/name replacement dictionary used by the cleaner.
- `references/tts-local-setup.md` — Piper model download, local TTS cron integration, MiniMax API key note.

## Legacy (OpenClaw)

OpenClaw used sherpa-onnx with `brief_text_clean.py` + `brief_replacements.json` for offline TTS. The cleaning script handled:
- Acronyms: BBC → 英国广播公司
- Names: Emmanuel Macron → 马克龙
- Numbers → Chinese characters
- Punctuation normalization for speech

These files are preserved in: `/home/kuhnn/SynologyDrive/openclaw_backup/snapshot_2026-03-09_031002/bin/`

**Note:** The current morning-briefing cron uses MiniMax TTS, which requires `MINIMAX_API_KEY` (set separately from `MINIMAX_CN_API_KEY` used for chat). TTS failures with "MINIMAX_API_KEY not set" mean the TTS key is missing — check that `MINIMAX_API_KEY` is in `.env`, not just `MINIMAX_CN_API_KEY`.

The user has provided the following instruction alongside the skill invocation: [IMPORTANT: You are running as a scheduled cron job. DELIVERY: Your final response will be automatically delivered to the user — do NOT use send_message or try to deliver the output yourself. Just produce your report/output as your final response and the system handles the rest. SILENT: If there is genuinely nothing new to report, respond with exactly "[SILENT]" (nothing else) to suppress delivery. Never combine [SILENT] with content — either report your findings normally, or say [SILENT] and nothing more.]

[IMPORTANT: You are running as a scheduled cron job. DELIVERY: Your final response will be automatically delivered to the user — do NOT use send_message or try to deliver the output yourself. Just produce your report/output as your final response and the system handles the rest. SILENT: If there is genuinely nothing new to report, respond with exactly "[SILENT]" (nothing else) to suppress delivery. Never combine [SILENT] with content — either report your findings normally, or say [SILENT] and nothing more.]

你是 K. W. 的早晨播报员。

## 第一步：加载环境变量
在调用 text_to_speech 之前，必须先加载 .env：
```bash
export $(grep MINIMAX_API_KEY /home/kuhnn/.hermes/.env | xargs)
```

## 第二步：搜索新闻和天气
用 web_search 搜索：
1. "今日头条 中国新闻" → 取 2-3 条重要新闻
2. "杭州天气 今天" → 获取温度和天气状况
3. "艺术行业新闻 中国" → 取 1 条艺术行业新闻（博物馆、画廊、拍卖、文化遗产等）

## 第三步：整理播报文本
整合成以下结构：

**开头**：K.W.，早上好！欢迎收听今天的信息播报。

**日期**：今天是二零二六年五月十八日，星期一。（用中文数字）

**新闻**：简述 2-3 条重要新闻，每条一句话。

**艺术动态**：1 条艺术行业新闻（博物馆、画廊、拍卖、文化遗产等），一句话。

**天气**：今天[城市]天气[状况]，气温[最低温度]到[最高温度]度。（温度用中文）

**结尾**：以上就是今天的播报，祝你有愉快的一天！

## 数字转换规则（重要！）
- 所有阿拉伯数字必须转为中文汉字
- 温度：18°C → "十八度"，27°C → "二十七度"
- 日期：5月18日 → "五月十八日"，星期一
- 年份：2026 → "二零二六"
- 百分比：85% → "百分之八十五"

## 第四步：TTS 语音生成

**优先使用 MiniMax TTS**（调用 text_to_speech 工具，provider: minimax），输出 .ogg 格式文件。

在回复末尾写：MEDIA:/home/kuhnn/.hermes/audio_cache/tts_YYYYMMDD_HHMMSS.ogg

**如果 MiniMax TTS 失败**（API key 问题或配额用完），才 fallback 到本地 Piper：
```bash
echo "播报文本" | ~/bin/tts_briefing.sh --out /home/kuhnn/.hermes/audio_cache/tts_$(date +%Y%m%d_%H%M%S).wav
ffmpeg -i /home/kuhnn/.hermes/audio_cache/tts_YYYYMMDD_HHMMSS.wav -acodec libopus /home/kuhnn/.hermes/audio_cache/tts_YYYYMMDD_HHMMSS.ogg -y
```

## 第五步：本地喇叭播放（重要！）
生成音频后，在本机喇叭上自动播放，音量 80%：
```bash
# 设置音量为 80%
pactl set-sink-volume alsa_output.pci-0000_00_1f.3.analog-stereo 80%
pactl set-sink-mute alsa_output.pci-0000_00_1f.3.analog-stereo false

# 播放音频（后台运行）
ffplay -nodisp -autoexit -volume 80 /home/kuhnn/.hermes/audio_cache/tts_YYYYMMDD_HHMMSS.ogg &
```

## 播报风格
亲切、自然，像朋友在给你说"早上好"。
内容控制在 400 字以内（大约 1-2 分钟语音）。

## Response

**Morning Briefing — 2026年5月18日 星期一**

---

**K.W.，早上好！欢迎收听今天的信息播报。**

**日期：** 二零二六年五月十八日，星期一。

---

**【重要新闻】**

1. **中美经贸合作新篇章** — 中美两国宣布共同成立"美中贸易委员会"和"美中投资委员会"，标志着两国经贸合作迈入新阶段。白宫证实，全球两大经济体将设立双边协调机制。

2. **MSCI中国A股新增硬科技龙头** — MSCI中国A股在岸指数本次新增十九只A股，多为硬科技龙头，包括长飞光纤、盛科通信、剑桥科技等，国际资本持续关注中国科技板块。

3. **中国新能源汽车保持全球领先** — 一季度新能源汽车销量突破三百万辆，继续保持全球最大新能源车市场地位，电动化转型加速推进。

---

**【艺术动态】**

**北京艺术季五月启幕** — 二零二六年北京艺术季将于五月二十一日重磅登场，以"艺聚北京 和合万方"为主题，汇聚近二十个国家、数百家艺术机构，推出超过四百场特色活动，邀请演员朱珠担任宣传大使，为市民打造全民艺术节日。

---

**【杭州天气】**

今天杭州天气多云转晴，气温二十二度到二十九度，适宜出行。

---

**音频播放中...**

MEDIA:/home/kuhnn/.hermes/audio_cache/tts_20260518_090000.ogg
