Alexa CLI技能使用说明
2026-03-28
新闻来源:网淘吧
围观:13
电脑广告
手机广告
Alexa CLI
使用alexacli通过非官方的 Alexa API 控制 Amazon Echo 设备和智能家居。
身份验证
# Browser login (recommended)
alexacli auth
# Non-US accounts
alexacli auth --domain amazon.de
alexacli auth --domain amazon.co.uk
# Check auth status
alexacli auth status
alexacli auth status --verify # validate token against API
# Remove credentials
alexacli auth logout
令牌有效期约为 14 天。配置存储在~/.alexa-cli/config.json文件中。
设备
alexacli devices
alexacli devices --json
文本转语音
# Speak on a specific device
alexacli speak "Hello world" -d "Kitchen Echo"
# Announce to ALL devices
alexacli speak "Dinner is ready!" --announce
# Device name matching is flexible
alexacli speak "Build complete" -d Kitchen
语音命令(智能家居控制)
发送任何命令,就像您对 Alexa 说话一样:
# Lights, switches, plugs
alexacli command "turn off the living room lights" -d Kitchen
alexacli command "dim the bedroom lights to 50 percent" -d Bedroom
# Thermostats
alexacli command "set thermostat to 72 degrees" -d Bedroom
alexacli command "what's the temperature inside" -d Kitchen
# Locks
alexacli command "lock the front door" -d Kitchen
# Music
alexacli command "play jazz music" -d "Living Room"
alexacli command "stop" -d "Living Room"
# Questions
alexacli command "what's the weather" -d Kitchen
# Timers
alexacli command "set a timer for 10 minutes" -d Kitchen
询问(获取响应)
发送命令并捕获 Alexa 的文本响应:
alexacli ask "what's the thermostat set to" -d Kitchen
# Output: The thermostat is set to 68 degrees.
alexacli ask "what's on my calendar today" -d Kitchen --json
Alexa+(LLM 对话)
与亚马逊基于 LLM 的助手交互:
# Quick start - auto-selects conversation
alexacli askplus -d "Echo Show" "What's the capital of France?"
# Multi-turn retains context
alexacli askplus -d "Echo Show" "What about Germany?"
# List conversations
alexacli conversations
# View conversation history
alexacli fragments "amzn1.conversation.xxx"
音频播放
通过 Echo 设备播放 MP3 音频:
alexacli play --url "https://example.com/audio.mp3" -d "Echo Show"
要求:MP3 格式,比特率 48kbps,采样率 22050Hz,HTTPS URL。
历史记录
alexacli history
alexacli history --limit 5
alexacli history --json
命令参考
| 命令 | 描述 |
|---|---|
alexacli 设备 | 列出所有 Echo 设备 |
alexacli 说话 <文本> -d <设备> | 设备上的文本转语音 |
alexacli 说话 <文本> --announce | 向所有设备广播 |
alexacli 命令 <文本> -d <设备> | 语音命令(智能家居、音乐等) |
alexacli 询问 <文本> -d <设备> | 发送命令,获取回应 |
alexacli 对话 | 列出 Alexa+ 对话 ID |
alexacli 片段 <id> | 查看 Alexa+ 对话历史 |
alexacli askplus -d <设备> <文本> | Alexa+ LLM 对话 |
alexacli 播放 --url <url> -d <设备> | 通过 SSML 播放 MP3 |
alexacli 认证 | 浏览器登录或手动令牌 |
alexacli 认证状态 [--verify] | 显示认证状态 |
alexacli auth logout | 移除凭证 |
alexacli history | 查看最近的语音活动 |
注意事项
- 使用亚马逊的非官方API(与Alexa应用程序相同)
- 刷新令牌有效期约14天,到期需重新运行
alexacli auth如果已过期 - 设备名称支持部分匹配,不区分大小写
- 对于AI/代理使用,
alexacli command建议使用自然语言 - 添加
--verbose或-v到任何命令中以获取调试输出
文章底部电脑广告
手机广告位-内容正文底部


微信扫一扫,打赏作者吧~