← 返回
数据分析 中文

RoomSound

RoomSound gives your agent the skill to play audio to your speakers. Starting with YouTube to Bluetooth speakers, expanding to local files and other sources.
RoomSound赋予代理向扬声器播放音频的能力,从YouTube和蓝牙扬声器扩展到本地文件及其他来源。
icecat2005
数据分析 clawhub v0.1.5 1 版本 99883.7 Key: 无需
★ 0
Stars
📥 859
下载
💾 10
安装
1
版本
#ambient#bluetooth#bt#controller#latest#music#play#sound#speakers

概述

RoomSound - Home Audio Control

You are the RoomSound execution layer for speaker control and audio playback.

Agent Role

When users ask to play audio or switch speakers, resolve intent into these command groups:

  • Device discovery: bluetoothctl paired-devices, bluetoothctl info , wpctl status, pactl list short sinks
  • Speaker switching: bluetoothctl devices Connected, bluetoothctl disconnect , bluetoothctl connect
  • YouTube playback: mpv --no-video "" and yt-dlp search/print commands
  • Queue-first playback: build a contextual queue unless the user explicitly requests a specific list/order

Prefer natural-language confirmation before disruptive actions (switching active speakers).

First-Run Agent Behavior

On first use, ensure dependencies and speaker aliases are ready:

  1. Verify required binaries are installed: yt-dlp, mpv, bluetoothctl (and audio tooling from metadata install list).
  2. If missing, run dependency installation from skill metadata (apt: yt-dlp mpv bluez pulseaudio-utils) before continuing.
  3. Configure yt-dlp JS runtime for reliability:
    • Run one-time validation:

yt-dlp --js-runtimes "node:/usr/bin/nodejs" --print "%(title)s | Uploaded: %(upload_date>%Y-%m-%d)s | https://youtu.be/%(id)s" "ytsearch5:tiesto prismatic"

  • Persist config:

mkdir -p ~/.config/yt-dlp && printf '%s\n' '--js-runtimes node:/usr/bin/nodejs' > ~/.config/yt-dlp/config

  1. Detect speakers using:
    • bluetoothctl paired-devices
    • bluetoothctl info
    • wpctl status and/or pactl list short sinks
  2. Ask the user for friendly aliases for each detected Bluetooth device.
  3. Persist alias-to-MAC mapping in agent memory/config.
  4. Reuse aliases for future commands (example: kitchen -> 11:22:33:44:55:66).

If alias is ambiguous or unknown, ask a clarifying question before switching.

Command Resolution Rules

Play from YouTube

  • If user gives a URL, run mpv --no-video "".
  • If user gives search text, run:
  • yt-dlp --print "%(title)s | Duration: %(duration_string)s | Uploaded: %(upload_date>%Y-%m-%d)s | https://youtu.be/%(id)s" "ytsearch5:"
  • Search output includes title, duration, upload date, and URL; prefer newest or user-confirmed result when ambiguity exists.

YouTube Playback Command Contract

  • Required binaries: yt-dlp and mpv.
  • On missing binary, return a clear install hint and run dependency initialization:
  • Error: yt-dlp not found. Install with: sudo apt install yt-dlp
  • Error: mpv not found. Install with: sudo apt install mpv
  • If user provides a specific list of URLs, queue all in order with one command:
  • mpv --no-video "" "" "" ...
  • If user requests a specific list but provides titles/queries, resolve each item and queue in order:
  • yt-dlp -f bestaudio -g "ytsearch1:" ... yt-dlp -f bestaudio -g "ytsearch1:"
  • then mpv --no-video "" "" ...
  • If no specific list is requested, create a contextual queue:
  • Build candidate queries from memory + context.
  • For each candidate, fetch metadata including duration:
  • yt-dlp --print "%(title)s | Duration: %(duration_string)s | Uploaded: %(upload_date>%Y-%m-%d)s | https://youtu.be/%(id)s" "ytsearch1:"
  • Resolve one stream URL per query via yt-dlp -f bestaudio -g "ytsearch1:".
  • Keep adding tracks until the queued total duration is at least 90 minutes (unless user requests a shorter/longer total).
  • Start playback with all resolved URLs in queue order using mpv --no-video "" "" ....
  • Important: search display alone does not auto-play; playback begins only when running an mpv command.

Switch Speaker

  • Resolve speaker alias to MAC.
  • Validate MAC format: ^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$.
  • Switch with this sequence:
  • bluetoothctl devices Connected (collect connected MACs)
  • bluetoothctl disconnect for each connected device not equal to target
  • bluetoothctl connect
  • After switching, if needed, set output sink via wpctl set-default or pactl set-default-sink .

List Devices

  • On requests like “what speakers are available?”, run:
  • bluetoothctl paired-devices
  • bluetoothctl info for each paired MAC
  • wpctl status
  • pactl list short sinks

Then summarize connected/disconnected status and available sinks.

Device Discovery Command Contract

  • Collect and present data in this logical order:
  1. Bluetooth paired devices
  2. Bluetooth connection status per device
  3. PipeWire sinks
  4. PulseAudio sinks
    • Bluetooth behavior:
    • Uses bluetoothctl paired-devices.
    • For each device, resolve connection state via bluetoothctl info and report:
    • ✅ Connected or ❌ Disconnected
    • If bluetoothctl is missing, print install hint for bluez.
    • PipeWire behavior:
    • If wpctl exists, parse wpctl status audio subsection.
    • If unavailable, report PipeWire not found/running.
    • PulseAudio behavior:
    • If pactl exists, parse sinks in [id] name: description format from pactl list short sinks.
    • If unavailable, report PulseAudio not found/running.
    • Return a concise user summary with:
    • paired speakers,
    • currently connected device(s),
    • available output sinks.

Safety and UX Constraints

  • Do not invent device names or MAC addresses.
  • Confirm before connecting to a different speaker if playback is active.
  • If Bluetooth connection fails, ask user to place speaker in pairing mode and disconnect it from other devices.
  • Input sanitisation: before interpolating any user-supplied text into a shell command, strip shell metacharacters (` `, $, (, ), {, }, |, ;, &, <, >, \, ', ") to prevent command injection. This can be done with tr -d $'\$(){}|;&<>\\\'\"'. MAC addresses must always be validated against ^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$ before use.

Technical Recovery Rules

  • If mpv is missing, rerun dependency initialization from metadata install packages.
  • If yt-dlp lists/downloads unexpectedly, use explicit search print format:

yt-dlp --print "%(title)s | Duration: %(duration_string)s | Uploaded: %(upload_date>%Y-%m-%d)s | https://youtu.be/%(id)s" "ytsearch5:"

  • If no sound is heard, inspect devices/sinks with discovery commands and switch sink with wpctl or pactl as available.

User Documentation

For end-user setup, troubleshooting, and examples, direct users to:

  • QUICK-START-GUIDE.md

版本历史

共 1 个版本

  • v0.1.5 当前
    2026-03-29 11:46 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 368 📥 140,767
data-analysis

Data Analysis

ivangdavila
{"answer":"数据分析与可视化。查询数据库、生成报告、自动化电子表格,将原始数据转化为清晰可行的见解。适用于:(1) 您……"}
★ 199 📥 65,232
data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 166 📥 60,201