Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

同一个docker支持几个型号的小爱 #65

Closed
jibwf opened this issue May 18, 2024 · 23 comments
Closed

同一个docker支持几个型号的小爱 #65

jibwf opened this issue May 18, 2024 · 23 comments
Labels
好建议 Good for newcomers 文档 帮助文档 新功能 可能会实现的功能 高优先级 优先制作的需求

Comments

@jibwf
Copy link
Contributor

jibwf commented May 18, 2024

家里好几个型号的小爱,可以用一个docker支持吗?现在好像只能开多个docker

@hanxi
Copy link
Owner

hanxi commented May 19, 2024

可以通过自己修改 dockerfile ,做一个支持启动同时多个的镜像来实现。

@jibwf
Copy link
Contributor Author

jibwf commented May 19, 2024

可以通过自己修改 dockerfile ,做一个支持启动同时多个的镜像来实现。

能给一个例子吗?

@hanxi
Copy link
Owner

hanxi commented May 19, 2024

需要有一点制作docker镜像的基础,比如现在的是只启动了一个 python :

FROM python:3.10 AS builder
WORKDIR /app
COPY requirements.txt .
RUN python3 -m venv .venv && .venv/bin/pip install --no-cache-dir -r requirements.txt
COPY install_dependencies.sh .
RUN bash install_dependencies.sh

FROM python:3.10-slim

WORKDIR /app
COPY --from=builder /app/.venv /app/.venv
COPY --from=builder /app/ffmpeg /app/ffmpeg
COPY xiaomusic/ ./xiaomusic/
COPY xiaomusic.py .
ENV XDG_CONFIG_HOME=/config
ENV XIAOMUSIC_HOSTNAME=192.168.2.5
ENV XIAOMUSIC_PORT=8090
VOLUME /config
EXPOSE 8090
ENV PATH=/app/.venv/bin:$PATH
ENTRYPOINT [".venv/bin/python3","xiaomusic.py"]

可以改成启动多个 python 的:

FROM python:3.10 AS builder
WORKDIR /app
COPY requirements.txt .
RUN python3 -m venv .venv && .venv/bin/pip install --no-cache-dir -r requirements.txt
COPY install_dependencies.sh .
RUN bash install_dependencies.sh

FROM python:3.10-slim

WORKDIR /app
COPY --from=builder /app/.venv /app/.venv
COPY --from=builder /app/ffmpeg /app/ffmpeg
COPY xiaomusic/ ./xiaomusic/
COPY xiaomusic.py .
COPY entrypoint.sh .
ENV XDG_CONFIG_HOME=/config
ENV XIAOMUSIC_HOSTNAME=192.168.2.5
VOLUME /config
EXPOSE 8090
EXPOSE 8091
ENV PATH=/app/.venv/bin:$PATH
ENTRYPOINT ["bash","entrypoint.sh"]

然后就可以在 entrypoint.sh 里写多个启动命令:

XIAOMUSIC_PORT=8090 .venv/bin/python3 xiaomusic.py --hardware=L07A &
XIAOMUSIC_PORT=8091 .venv/bin/python3 xiaomusic.py --hardware=L07A

上面只是伪代码,没测试过的。有兴趣可以自己摸索下。

@hanxi hanxi added the 新功能 可能会实现的功能 label Jun 12, 2024
@hanxi hanxi added the 好建议 Good for newcomers label Jun 28, 2024
@bonnyandsky
Copy link

这个功能现在实现了么??我家里也有几个不同的小爱音响

@hanxi
Copy link
Owner

hanxi commented Jun 29, 2024

还没有呢

@LeanFly
Copy link

LeanFly commented Jul 3, 2024

那这得改很多东西了

@hanxi
Copy link
Owner

hanxi commented Jul 3, 2024

预计会修改代码来实现,而不是新增端口。新增端口的方式无法做到同时播放。

@LeanFly
Copy link

LeanFly commented Jul 3, 2024

感觉可能得改成使用配置文件的方式来处理了,多设备时用列表存储设备信息

@hanxi
Copy link
Owner

hanxi commented Jul 5, 2024

目前测试版本 main 包已经支持多设备,欢迎更新测试。直接在设置页面选择需要同时播放的设备,保存即可。

@jibwf
Copy link
Contributor Author

jibwf commented Jul 7, 2024

勾选多设备后,任何一个小爱同学都无法监听到本地指令了。本地控制页面播放可以同时推送到两个小爱同学。

只够选任何单独的小爱同学都
Uploading xiaomusic (1).txt…
没有问题。

@jibwf
Copy link
Contributor Author

jibwf commented Jul 7, 2024

@hanxi 感谢大佬的快速更新

@hanxi
Copy link
Owner

hanxi commented Jul 7, 2024

@jibwf 你用的哪个版本呢?你的日志可以再上传一下吗?,下载不了。

@jibwf
Copy link
Contributor Author

jibwf commented Jul 7, 2024

@jibwf 你用的哪个版本呢?你的日志可以再上传一下吗?,下载不了。

@hanxi 最新版0.1.97
xiaomusic (1).txt

@jibwf
Copy link
Contributor Author

jibwf commented Jul 7, 2024

日志里那个时间点好像没有任何信息。 我已经重启过容器了,还是不行。

@hanxi
Copy link
Owner

hanxi commented Jul 7, 2024

日志里那个时间点好像没有任何信息。 我已经重启过容器了,还是不行。

我先看看哈,没有多个设备,不太好调试。

@hanxi
Copy link
Owner

hanxi commented Jul 7, 2024

我看出问题了,下个版本修复

@hanxi
Copy link
Owner

hanxi commented Jul 7, 2024

https://github.com/hanxi/xiaomusic/releases/tag/v0.1.98 新版本已出。

@jibwf
Copy link
Contributor Author

jibwf commented Jul 7, 2024

@hanxi 0.1.99版本 对话记录没问题了,但是发现同一个指令,多个小爱音箱都会执行。理想状态是只有获取到指令的小爱执行。

@jibwf
Copy link
Contributor Author

jibwf commented Jul 7, 2024

[
xiaomusic (3).txt
](url)

@hanxi
Copy link
Owner

hanxi commented Jul 7, 2024

确实没有考虑这个问题。目前的实现方案就是用来同时播放的。如果要做到语音分开播放,就还得同时搞定网页里播放的问题。后期考虑做一个分组功能,把分在一组的设备一起控制。

@hanxi
Copy link
Owner

hanxi commented Jul 9, 2024

多设备单独播放功能设计

分组功能

为设备设计分组功能,可以把一个或者多个设备加入到一个分组,一个分组内的设备会被控制同时播放。设备的音量需要支持独立配置。

分组用 group_list 字段配置,比如 did1:客厅,did2:客厅 表示 did1和did2用同一个组名。不配置这个参数就说明一个设备一个分组。后台勾选设备的意图改为哪些设备可以接入。

单个设备的存储配置结构如下:

{
  "devices": {
    "10086": {
      "cur_music": "当前播放的歌曲",
      "cur_playlist": "当前播放的列表",
      "name": "客厅的小爱1",
      "play_type": 1
    },
    "10087": {
      "cur_music": "当前播放的歌曲",
      "cur_playlist": "当前播放的列表",
      "name": "客厅的小爱2",
      "play_type": 1
    }
  }
}

设备名字从音箱app设置里读取过来,不用在后台修改。

配置采用组名相同为一组,可以考虑不设置组名就用设备名作为组名,也就是一个设备为一组。

后端提供的接口都改为支持操作多个设备,

单曲循环,随机播放这些操作都会同步修改同一个组里的其他设备。

歌单列表所有设备共享,当前选择的歌单和当前播放的歌曲组内共享,一个组共用一份播放列表,也就是共用一个定时器。

主页设备切换

主页主要是用于播放操作的,所有操作都是针对于单个设备的,所以在顶部加入一个切换设备的功能。除了修改声音不会同步修改组内设备,其他操作都会同时操作组内所有设备。

@hanxi hanxi added the 高优先级 优先制作的需求 label Jul 10, 2024
hanxi added a commit that referenced this issue Jul 10, 2024
hanxi added a commit that referenced this issue Jul 11, 2024
@hanxi
Copy link
Owner

hanxi commented Jul 11, 2024

多个设备分开播放的功能已经合并到 main 分支,希望有多个设备的朋友可以帮忙测试测试。在镜像后面加 :main 即可更新到。格式如下:

docker pull hanxi/xiaomusic:main

@hanxi
Copy link
Owner

hanxi commented Jul 14, 2024

0.3.0 版本支持

@hanxi hanxi closed this as completed Jul 14, 2024
@hanxi hanxi added the 文档 帮助文档 label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
好建议 Good for newcomers 文档 帮助文档 新功能 可能会实现的功能 高优先级 优先制作的需求
Projects
None yet
Development

No branches or pull requests

4 participants