1
0
mirror of https://github.com/hanxi/xiaomusic.git synced 2025-12-06 14:52:50 +08:00

Compare commits

..

31 Commits

Author SHA1 Message Date
Issues Docs [BOT]
7c8bde5808 Auto-Generate docs 🤖 2025-10-29 21:08:33 +00:00
Issues Docs [BOT]
4645bd393b Auto-Generate docs 🤖 2025-10-29 06:27:53 +00:00
涵曦
841962660e Update README.md 2025-10-29 14:25:59 +08:00
Issues Docs [BOT]
6c434dd7d6 Auto-Generate docs 🤖 2025-10-27 16:05:52 +00:00
涵曦
7680fa2dd6 bump: version 0.3.95 → 0.3.96 2025-10-28 00:03:37 +08:00
涵曦
3db75c64c2 build: update static version 2025-10-28 00:03:37 +08:00
Issues Docs [BOT]
6534066b7e Auto-Generate docs 🤖 2025-10-26 13:03:57 +00:00
涵曦
0e3576cf10 fix: tts问题临时处理 2025-10-26 20:53:27 +08:00
Issues Docs [BOT]
9fc4d8f5ee Auto-Generate docs 🤖 2025-10-26 04:24:17 +00:00
涵曦
a74546e8d6 bump: version 0.3.94 → 0.3.95 2025-10-26 12:22:08 +08:00
涵曦
d2fb5ab8d4 build: update static version 2025-10-26 12:22:08 +08:00
涵曦
e855ffd457 fix: 修复型号M01不能播放问题 2025-10-26 12:21:46 +08:00
Issues Docs [BOT]
71cdfd6cda Auto-Generate docs 🤖 2025-10-25 10:06:33 +00:00
涵曦
82f5602f4c bump: version 0.3.93 → 0.3.94 2025-10-25 18:02:44 +08:00
涵曦
11028a5812 build: update static version 2025-10-25 18:02:44 +08:00
涵曦
ecd7e90533 fix: 尝试修复登录问题 2025-10-25 18:02:25 +08:00
Issues Docs [BOT]
cfc34d1e97 Auto-Generate docs 🤖 2025-10-25 09:57:03 +00:00
涵曦
dc0101f94e bump: version 0.3.92 → 0.3.93 2025-10-25 17:54:38 +08:00
涵曦
912e8eecf2 build: update static version 2025-10-25 17:54:37 +08:00
涵曦
2dd1242532 fix: 尝试修复登录问题 2025-10-25 17:52:33 +08:00
Issues Docs [BOT]
7b947da5c1 Auto-Generate docs 🤖 2025-10-25 09:26:09 +00:00
涵曦
6f877d3203 bump: version 0.3.91 → 0.3.92 2025-10-25 17:24:08 +08:00
涵曦
07a78a81b6 build: update static version 2025-10-25 17:24:08 +08:00
Issues Docs [BOT]
e2950bbfd7 Auto-Generate docs 🤖 2025-10-25 09:01:17 +00:00
涵曦
df8105f34f build: 尝试修复打包问题 2025-10-25 16:59:06 +08:00
涵曦
8c95c85b00 build: 尝试修复打包问题 2025-10-25 16:21:39 +08:00
涵曦
ed1f1c6bf4 build: 尝试修复打包问题 2025-10-25 16:17:40 +08:00
涵曦
02edfe4bee Update README.md 2025-10-25 16:01:48 +08:00
涵曦
40f12f37e1 build: 修复打包问题 2025-10-25 15:56:21 +08:00
涵曦
7fb5ea4992 fix: 尝试解决登录失败问题 2025-10-25 15:44:35 +08:00
Issues Docs [BOT]
9bd99ab7ce Auto-Generate docs 🤖 2025-10-24 12:23:44 +00:00
23 changed files with 175 additions and 39 deletions

View File

@@ -19,6 +19,9 @@ jobs:
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx

View File

@@ -25,6 +25,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

View File

@@ -18,6 +18,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Setup PDM
uses: pdm-project/setup-pdm@v4

View File

@@ -51,6 +51,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Node.js
uses: actions/setup-node@v2

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "MiService"]
path = MiService
url = git@github.com:hanxi/MiService.git

View File

@@ -1,3 +1,33 @@
## v0.3.96 (2025-10-28)
### Fix
- tts问题临时处理
## v0.3.95 (2025-10-26)
### Fix
- 修复型号M01不能播放问题
## v0.3.94 (2025-10-25)
### Fix
- 尝试修复登录问题
## v0.3.93 (2025-10-25)
### Fix
- 尝试修复登录问题
## v0.3.92 (2025-10-25)
### Fix
- 尝试解决登录失败问题
## v0.3.91 (2025-10-24)
### Feat

View File

@@ -7,7 +7,8 @@ COPY xiaomusic/ ./xiaomusic/
COPY plugins/ ./plugins/
COPY holiday/ ./holiday/
COPY xiaomusic.py .
RUN pdm install --prod --no-editable
COPY MiService/ ./MiService/
RUN pdm install --prod --no-editable -v
FROM hanxi/xiaomusic:runtime
WORKDIR /app

View File

@@ -5,10 +5,12 @@ RUN pip install -U pdm
ENV PDM_CHECK_UPDATE=false
WORKDIR /app
COPY pyproject.toml README.md ./
COPY MiService/ ./MiService/
RUN pdm install --prod --no-editable
RUN pdm install --prod --no-editable -v
COPY xiaomusic/ ./xiaomusic/
COPY plugins/ ./plugins/
COPY holiday/ ./holiday/
COPY MiService/ ./MiService/
COPY xiaomusic.py .

1
MiService Submodule

Submodule MiService added at 898d7de17f

View File

@@ -271,8 +271,9 @@ docker build -t xiaomusic .
## 📢 讨论区
- [点击链接加入QQ频道【xiaomusic】](https://pd.qq.com/s/e2jybz0ss)
- [点击链接加入群聊【满 xiaomusic官方交流群1(小爱音箱)】 604526973](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=13St5PLVcTxYlWTAs_iAawazjtdD1l-a&authKey=dJWEpaT2fDBDpdUUOWj%2FLt6NS1ePBfShDfz7a6seNURi05VvVnAGQzXF%2FM%2F5HgIm&noverify=0&group_code=604526973)
- [点击链接加入群聊【xiaomusic官方交流群2(小爱音箱)】1021062499](https://qm.qq.com/q/BmVNqhDL3M)
- [点击链接加入群聊【满 xiaomusic官方交流群1】 604526973](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=13St5PLVcTxYlWTAs_iAawazjtdD1l-a&authKey=dJWEpaT2fDBDpdUUOWj%2FLt6NS1ePBfShDfz7a6seNURi05VvVnAGQzXF%2FM%2F5HgIm&noverify=0&group_code=604526973)
- [点击链接加入群聊【xiaomusic官方交流群2】1021062499](https://qm.qq.com/q/BmVNqhDL3M)
- [点击链接加入群聊【xiaomusic官方交流群3】 1072151477](https://qm.qq.com/q/lxIhquqbza)
- <https://github.com/hanxi/xiaomusic/issues>
- [微信群二维码](https://github.com/hanxi/xiaomusic/issues/86)

View File

@@ -4,7 +4,7 @@ title: 微信交流群二维码
# 微信交流群二维码
<img width="1031" height="1440" alt="Image" src="https://gproxy.hanxi.cc/proxy/user-attachments/assets/ea6aeb44-69cf-4a6a-a46c-ebab6dbf657a" />
<img width="1031" height="1440" alt="Image" src="https://gproxy.hanxi.cc/proxy/user-attachments/assets/25cf3a96-06d9-485c-b37d-b9fc262636ab" />
## 评论

View File

@@ -1906,5 +1906,11 @@ Bilibili现在也需要cookies建议作者大大改一下改一下说明。
大佬可以进个群吗?
---
### 评论 131 - lucklyday2023
L06A 测试-播放文字无效web界面和语音控制无提示音
---
[链接到 GitHub Issue](https://github.com/hanxi/xiaomusic/issues/99)

View File

@@ -1,5 +1,46 @@
# 版本日志
## v0.3.96 (2025-10-28)
### Fix
- tts问题临时处理
## v0.3.95 (2025-10-26)
### Fix
- 修复型号M01不能播放问题
## v0.3.94 (2025-10-25)
### Fix
- 尝试修复登录问题
## v0.3.93 (2025-10-25)
### Fix
- 尝试修复登录问题
## v0.3.92 (2025-10-25)
### Fix
- 尝试解决登录失败问题
## v0.3.91 (2025-10-24)
### Feat
- 删掉没用的网页更新功能
- 获取对话记录接口修改
### Fix
- 尝试修复登录问题
## v0.3.90 (2025-10-22)
### Fix

View File

@@ -271,8 +271,9 @@ docker build -t xiaomusic .
## 📢 讨论区
- [点击链接加入QQ频道【xiaomusic】](https://pd.qq.com/s/e2jybz0ss)
- [点击链接加入群聊【满 xiaomusic官方交流群1(小爱音箱)】 604526973](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=13St5PLVcTxYlWTAs_iAawazjtdD1l-a&authKey=dJWEpaT2fDBDpdUUOWj%2FLt6NS1ePBfShDfz7a6seNURi05VvVnAGQzXF%2FM%2F5HgIm&noverify=0&group_code=604526973)
- [点击链接加入群聊【xiaomusic官方交流群2(小爱音箱)】1021062499](https://qm.qq.com/q/BmVNqhDL3M)
- [点击链接加入群聊【满 xiaomusic官方交流群1】 604526973](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=13St5PLVcTxYlWTAs_iAawazjtdD1l-a&authKey=dJWEpaT2fDBDpdUUOWj%2FLt6NS1ePBfShDfz7a6seNURi05VvVnAGQzXF%2FM%2F5HgIm&noverify=0&group_code=604526973)
- [点击链接加入群聊【xiaomusic官方交流群2】1021062499](https://qm.qq.com/q/BmVNqhDL3M)
- [点击链接加入群聊【xiaomusic官方交流群3】 1072151477](https://qm.qq.com/q/lxIhquqbza)
- <https://github.com/hanxi/xiaomusic/issues>
- [微信群二维码](https://github.com/hanxi/xiaomusic/issues/86)

View File

@@ -1,13 +1,12 @@
[project]
name = "xiaomusic"
version = "0.3.91"
version = "0.3.96"
description = "Play Music with xiaomi AI speaker"
authors = [
{name = "涵曦", email = "im.hanxi@gmail.com"},
]
dependencies = [
"aiohttp>=3.8.6",
"miservice-fork>=2.7.0",
"watchdog>=6.0.0",
"mutagen>=1.47.0",
"yt-dlp[default]>=2024.12.1.232904.dev0",
@@ -24,7 +23,9 @@ dependencies = [
"sentry-sdk[fastapi]==1.45.1",
"python-socketio>=5.12.1",
"pyjwt>=2.10.1",
"fake-useragent>=2.2.0",
"fake-useragent>=2.2.0",
"miservice-fork @ file:///${PROJECT_ROOT}/MiService",
"edge-tts>=7.2.3",
]
requires-python = ">=3.10"
readme = "README.md"
@@ -77,9 +78,9 @@ extend-immutable-calls = [
]
[tool.pdm.scripts]
lint = "ruff check ."
fmt = "ruff format ."
lintfmt = {composite = ["ruff check --fix .", "ruff format ."]}
lint = "ruff check . --exclude MiService"
fmt = "ruff format . --exclude MiService"
lintfmt = {composite = ["ruff check --fix . --exclude MiService", "ruff format . --exclude MiService"]}
[tool.commitizen]
name = "cz_conventional_commits"

View File

@@ -1 +1 @@
__version__ = "0.3.91"
__version__ = "0.3.96"

View File

@@ -6,9 +6,9 @@
<meta name="viewport" content="width=device-width">
<title>Debug For XiaoMusic</title>
<link rel="stylesheet" type="text/css" href="./main.css?version=1761308477">
<link rel="stylesheet" type="text/css" href="./main.css?version=1761581012">
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<script src="./jquery-3.7.1.min.js?version=1761308477"></script>
<script src="./jquery-3.7.1.min.js?version=1761581012"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z09NC1K7ZW"></script>

View File

@@ -4,8 +4,8 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>歌曲下载工具</title>
<link rel="stylesheet" type="text/css" href="./main.css?version=1761308477">
<script src="./jquery-3.7.1.min.js?version=1761308477"></script>
<link rel="stylesheet" type="text/css" href="./main.css?version=1761581012">
<script src="./jquery-3.7.1.min.js?version=1761581012"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z09NC1K7ZW"></script>

View File

@@ -5,8 +5,8 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>小爱音箱操控面板</title>
<script src="./jquery-3.7.1.min.js?version=1761308477"></script>
<link rel="stylesheet" href="./main.css?version=1761308477">
<script src="./jquery-3.7.1.min.js?version=1761581012"></script>
<link rel="stylesheet" href="./main.css?version=1761581012">
<link rel="icon" href="./favicon.ico">
<!-- Google tag (gtag.js) -->
@@ -196,7 +196,7 @@
Powered by XiaoMusic
</div>
<script src="./md.js?version=1761308477">
<script src="./md.js?version=1761581012">
</script>
</body>

View File

@@ -5,7 +5,7 @@
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width">
<title>M3U to JSON Converter</title>
<link rel="stylesheet" type="text/css" href="./main.css?version=1761308477">
<link rel="stylesheet" type="text/css" href="./main.css?version=1761581012">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z09NC1K7ZW"></script>

View File

@@ -4,9 +4,9 @@
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width">
<title>小爱音箱操控面板</title>
<script src="./jquery-3.7.1.min.js?version=1761308477"></script>
<script src="./setting.js?version=1761308477"></script>
<link rel="stylesheet" type="text/css" href="./main.css?version=1761308477">
<script src="./jquery-3.7.1.min.js?version=1761581012"></script>
<script src="./setting.js?version=1761581012"></script>
<link rel="stylesheet" type="text/css" href="./main.css?version=1761581012">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z09NC1K7ZW"></script>

View File

@@ -24,10 +24,12 @@ from collections import OrderedDict
from collections.abc import AsyncIterator
from dataclasses import asdict, dataclass
from http.cookies import SimpleCookie
from pathlib import Path
from time import sleep
from urllib.parse import parse_qs, urlparse
import aiohttp
import edge_tts
import mutagen
from mutagen.asf import ASF
from mutagen.flac import FLAC
@@ -1466,3 +1468,41 @@ class MusicUrlCache:
def size(self) -> int:
"""当前缓存大小"""
return len(self.cache)
async def text_to_mp3(
text: str, save_dir: str, voice: str = "zh-CN-XiaoxiaoNeural"
) -> str:
"""
使用edge-tts将文本转换为MP3语音文件
参数:
text: 需要转换的文本内容
save_dir: 保存MP3文件的目录路径
voice: 语音模型(默认中文晓晓)
返回:
str: 生成的MP3文件完整路径
"""
# 确保保存目录存在
Path(save_dir).mkdir(parents=True, exist_ok=True)
# 基于文本和语音模型生成唯一文件名(避免相同文本不同语音重复)
content = f"{text}_{voice}".encode()
file_hash = hashlib.md5(content).hexdigest()
mp3_filename = f"{file_hash}.mp3"
mp3_path = os.path.join(save_dir, mp3_filename)
# 文件已存在直接返回路径
if os.path.exists(mp3_path):
return mp3_path
# 调用edge-tts生成语音
try:
communicate = edge_tts.Communicate(text, voice)
await communicate.save(mp3_path)
log.info(f"语音文件生成成功: {mp3_path}")
except Exception as e:
raise RuntimeError(f"生成语音文件失败: {e}") from e
return mp3_path

View File

@@ -15,7 +15,7 @@ from dataclasses import asdict
from logging.handlers import RotatingFileHandler
from aiohttp import ClientSession, ClientTimeout
from miservice import MiAccount, MiIOService, MiNAService, miio_command
from miservice import MiAccount, MiIOService, MiNAService
from watchdog.events import (
FileCreatedEvent,
FileDeletedEvent,
@@ -42,7 +42,6 @@ from xiaomusic.const import (
PLAY_TYPE_SEQ,
PLAY_TYPE_SIN,
SUPPORT_MUSIC_TYPE,
TTS_COMMAND,
)
from xiaomusic.crontab import Crontab
from xiaomusic.plugin import PluginManager
@@ -245,6 +244,7 @@ class XiaoMusic:
self.mi_token_home = os.path.join(self.config.conf_path, ".mi.token")
is_need_login = await self.need_login()
if is_need_login:
self.log.info("try login")
await self.login_miboy(session)
else:
self.log.info("already logined")
@@ -285,6 +285,7 @@ class XiaoMusic:
self.miio_service = MiIOService(account)
self.login_acount = self.config.account
self.login_password = self.config.password
self.log.info(f"登录完成. {self.login_acount}")
except Exception as e:
self.mina_service = None
self.miio_service = None
@@ -2045,20 +2046,22 @@ class XiaoMusicDevice:
async def text_to_speech(self, value):
try:
# 有 tts command 优先使用 tts command 说话
if self.hardware in TTS_COMMAND:
tts_cmd = TTS_COMMAND[self.hardware]
self.log.info("Call MiIOService tts.")
value = value.replace(" ", ",") # 不能有空格
await miio_command(
self.xiaomusic.miio_service,
self.did,
f"{tts_cmd} {value}",
)
else:
self.log.debug("Call MiNAService tts.")
await self.xiaomusic.mina_service.text_to_speech(self.device_id, value)
# if self.hardware in TTS_COMMAND:
# tts_cmd = TTS_COMMAND[self.hardware]
# self.log.info("Call MiIOService tts.")
# value = value.replace(" ", ",") # 不能有空格
# await miio_command(
# self.xiaomusic.miio_service,
# self.did,
# f"{tts_cmd} {value}",
# )
# else:
self.log.debug("Call MiNAService tts.")
await self.xiaomusic.mina_service.text_to_speech(self.device_id, value)
except Exception as e:
self.log.exception(f"Execption {e}")
# 重新初始化
# await self.xiaomusic.reinit()
# 同一组设备播放
async def group_player_play(self, url, name=""):