Skip to content

[zh-TW] Add media player intents (transport, volume, search and play) - #4025

Merged
bluefoxlee merged 4 commits into
OHF-Voice:mainfrom
parkghost:zh-tw/add-media-intents
Jul 29, 2026
Merged

[zh-TW] Add media player intents (transport, volume, search and play)#4025
bluefoxlee merged 4 commits into
OHF-Voice:mainfrom
parkghost:zh-tw/add-media-intents

Conversation

@parkghost

Copy link
Copy Markdown
Contributor

Changes

Adds the media player intents to zh-TW (Traditional Chinese), covering all 31 slot combinations intents.yaml defines for them.

Transport & volume (23 combinations, default / name_only / area_only, plus floor_only for volume)

  • HassMediaPause / HassMediaUnpause — 暫停 / 繼續播放
  • HassMediaNext / HassMediaPrevious — 下一首 / 上一首
  • HassMediaPlayerMute / HassMediaPlayerUnmute — 靜音 / 取消靜音
  • HassSetVolume — 把電視的音量調到50%
  • HassSetVolumeRelative — 把電視的音量調大 / 調高20%

HassMediaSearchAndPlay (8 combinations)

  • 播放五月天 / 在客廳播放五月天 / 在電視上播放五月天 / 播放五月天的歌

media_class maps the terms people actually use: 歌手→artist, 專輯→album, 歌|歌曲→track, 播放清單|歌單→playlist, 播客→podcast, 電影→movie, 影集|電視劇→tv_show.

Taiwan vocabulary: 音量 rather than 聲音 for volume, 靜音 for mute, 繼續播放 for unpause.

Testing

  • python3 -m script.intentfest validate --language zh-TW — All good!
  • pytest tests --language zh-TW — 262 passed

Two commits are test-only, covering paths the happy-path tests would miss:

  • Chinese numerals and volume range boundaries. The volume tests only used Arabic numerals (20/50) and never touched the ends of the 0-100 / -100-100 ranges. 把電視的音量調到五十 already resolved correctly; the test pins it so a change to the shared range lists in lists/media.yaml, or to hassil's number parsing, cannot silently break it.
  • search_query wildcard boundaries. The wildcard was only ever fed plain Chinese values. Added an English query, which keeps its internal whitespace even though zh-TW sets ignore_whitespace, and a query that itself contains 的 (播放五月天的歌的專輯), confirming the wildcard splits at the last 的 + media_class rather than the first.

Also verified against a live Home Assistant instance with a custom home-assistant-intents build:

  • 把 靜音 / 取消靜音, 把 的音量調到 30% and 調到五十 all resolved and executed correctly
  • 在臥室播放玫瑰人生 (area_only) and 在臥室音響上播放孤寂 (name_only) both matched and played the expected track from the local library via Music Assistant

…mute/volume)

- Transport controls incl. context-area, name and area combos
- HassSetVolume/HassSetVolumeRelative with 百分之X / X% / X趴 forms and
  direction words (調大|大聲一點 -> up)
The existing volume tests only used Arabic numerals (20/50), leaving two
gaps: Chinese numerals, which is how people actually speak, and the ends
of the 0-100 / -100-100 ranges.

Both already work — this pins the behaviour so a change to the shared
range lists or to hassil's number parsing cannot silently break it.
- Uses the 播放X的歌/專輯 (query-first) form: hassil's recognize_best
  tie-break (wildcards, then literal chunks; list matches don't count)
  means a class-first form (播放歌手五月天) can never beat the plain
  播放{search_query} template, so the media_class templates carry a
  required 的 to win
- media_class values use Taiwan vocabulary (影片/電影/播客|podcast/影集)
The search_query wildcard was only ever fed two plain Chinese values.
Adds the cases most likely to break it:

- an English query, which keeps its internal whitespace even though
  zh-TW sets ignore_whitespace
- a query that itself contains 的, confirming the wildcard splits at the
  last 的 + media_class rather than the first
@parkghost
parkghost requested a review from bluefoxlee as a code owner July 29, 2026 07:00
@bluefoxlee
bluefoxlee merged commit a05af51 into OHF-Voice:main Jul 29, 2026
2 checks passed
@parkghost
parkghost deleted the zh-tw/add-media-intents branch July 29, 2026 12:40
bluefoxlee added a commit that referenced this pull request Jul 30, 2026
…ests (#4026)

The two English examples added in #4025 pass this repo's CI but fail the
packaging sanity check in OHF-Voice/intents-package, because zh-TW sets
ignore_whitespace and the packaged data applies it while this repo's test
fixture does not.

Replaces them with Chinese examples that resolve to the same value under
either configuration.

Co-authored-by: bluefoxlee <jerrylee@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants