myagent-ai 1.15.97 → 1.15.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/update_manager.py +18 -0
- package/main.py +1 -1
- package/package.json +1 -1
- package/web/tts_handler.py +32 -20
package/core/update_manager.py
CHANGED
|
@@ -1101,6 +1101,24 @@ class UpdateManager:
|
|
|
1101
1101
|
|
|
1102
1102
|
async def _auto_check_loop(self):
|
|
1103
1103
|
"""后台自动检查循环"""
|
|
1104
|
+
# [v1.15.97] 启动后立即执行一次检查,不等间隔
|
|
1105
|
+
try:
|
|
1106
|
+
logger.info("执行启动时版本检查...")
|
|
1107
|
+
info = await self.check_for_update()
|
|
1108
|
+
if info.has_update:
|
|
1109
|
+
logger.info(
|
|
1110
|
+
f"发现新版本: {info.latest_version} "
|
|
1111
|
+
f"(当前: {info.current_version})"
|
|
1112
|
+
)
|
|
1113
|
+
try:
|
|
1114
|
+
await self.apply_update(UpdateType.FULL)
|
|
1115
|
+
except Exception as e:
|
|
1116
|
+
logger.error(f"自动更新失败: {e}")
|
|
1117
|
+
except asyncio.CancelledError:
|
|
1118
|
+
return
|
|
1119
|
+
except Exception as e:
|
|
1120
|
+
logger.error(f"启动时检查异常: {e}")
|
|
1121
|
+
|
|
1104
1122
|
while self._auto_check_enabled:
|
|
1105
1123
|
try:
|
|
1106
1124
|
await asyncio.sleep(self._auto_check_interval)
|
package/main.py
CHANGED
|
@@ -1518,7 +1518,7 @@ def main():
|
|
|
1518
1518
|
|
|
1519
1519
|
# 启动自动更新检查(后台)
|
|
1520
1520
|
if app.update_manager:
|
|
1521
|
-
asyncio.create_task(app.update_manager.start_auto_check(interval=
|
|
1521
|
+
asyncio.create_task(app.update_manager.start_auto_check(interval=600))
|
|
1522
1522
|
|
|
1523
1523
|
app._running_service = web_port or app.chat_manager
|
|
1524
1524
|
if args.tray:
|
package/package.json
CHANGED
package/web/tts_handler.py
CHANGED
|
@@ -152,28 +152,40 @@ async def synthesize(
|
|
|
152
152
|
all_audio += cache_path.read_bytes()
|
|
153
153
|
continue
|
|
154
154
|
|
|
155
|
-
# 调用 edge-tts
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
audio_data = b""
|
|
159
|
-
async for chunk_data in communicate.stream():
|
|
160
|
-
if chunk_data["type"] == "audio":
|
|
161
|
-
audio_data += chunk_data["data"]
|
|
162
|
-
|
|
163
|
-
if not audio_data:
|
|
164
|
-
logger.warning(f"TTS 块 {i} 生成空音频")
|
|
165
|
-
continue
|
|
166
|
-
|
|
167
|
-
# 写入缓存
|
|
155
|
+
# 调用 edge-tts(最多重试 2 次)
|
|
156
|
+
max_retries = 2
|
|
157
|
+
for attempt in range(max_retries):
|
|
168
158
|
try:
|
|
169
|
-
|
|
159
|
+
communicate = edge_tts.Communicate(chunk, voice, rate=speed)
|
|
160
|
+
audio_data = b""
|
|
161
|
+
async for chunk_data in communicate.stream():
|
|
162
|
+
if chunk_data["type"] == "audio":
|
|
163
|
+
audio_data += chunk_data["data"]
|
|
164
|
+
|
|
165
|
+
if not audio_data:
|
|
166
|
+
logger.warning(f"TTS 块 {i} 生成空音频 (重试 {attempt + 1}/{max_retries})")
|
|
167
|
+
if attempt < max_retries - 1:
|
|
168
|
+
await asyncio.sleep(0.5)
|
|
169
|
+
continue
|
|
170
|
+
else:
|
|
171
|
+
break
|
|
172
|
+
|
|
173
|
+
# 写入缓存
|
|
174
|
+
try:
|
|
175
|
+
cache_path.write_bytes(audio_data)
|
|
176
|
+
except Exception as e:
|
|
177
|
+
logger.debug(f"TTS 缓存写入失败: {e}")
|
|
178
|
+
|
|
179
|
+
all_audio += audio_data
|
|
180
|
+
break
|
|
170
181
|
except Exception as e:
|
|
171
|
-
logger.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
182
|
+
logger.warning(f"TTS 合成失败 (块 {i}, 重试 {attempt + 1}/{max_retries}): {e}")
|
|
183
|
+
if attempt < max_retries - 1:
|
|
184
|
+
await asyncio.sleep(0.5)
|
|
185
|
+
else:
|
|
186
|
+
logger.error(f"TTS 合成最终失败 (块 {i}): {e}")
|
|
187
|
+
# 不 raise,跳过这个块继续合成后面的
|
|
188
|
+
break
|
|
177
189
|
|
|
178
190
|
if not all_audio:
|
|
179
191
|
raise RuntimeError("语音合成结果为空")
|