myagent-ai 1.15.64 → 1.15.66
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/deps_checker.py +4 -3
- package/package.json +1 -1
- package/requirements.txt +0 -1
- package/web/api_server.py +43 -4
package/core/deps_checker.py
CHANGED
|
@@ -12,7 +12,7 @@ core/deps_checker.py - 自动依赖检测与安装
|
|
|
12
12
|
|
|
13
13
|
依赖映射:
|
|
14
14
|
核心功能: openai, aiohttp, requests
|
|
15
|
-
搜索技能:
|
|
15
|
+
搜索技能: bs4
|
|
16
16
|
系统技能: psutil
|
|
17
17
|
托盘功能: pystray, PIL
|
|
18
18
|
语音合成: edge_tts
|
|
@@ -62,7 +62,6 @@ DEPENDENCIES: List[DepInfo] = [
|
|
|
62
62
|
DepInfo("requests", "requests", "2.31.0", "core", "all"),
|
|
63
63
|
|
|
64
64
|
# ── 搜索技能 ──
|
|
65
|
-
DepInfo("duckduckgo_search", "duckduckgo-search", "6.0.0", "search", "all"),
|
|
66
65
|
DepInfo("bs4", "beautifulsoup4", "4.12.0", "search", "all"),
|
|
67
66
|
|
|
68
67
|
# ── 系统技能 ──
|
|
@@ -77,7 +76,9 @@ DEPENDENCIES: List[DepInfo] = [
|
|
|
77
76
|
|
|
78
77
|
# ── 语音识别 (STT) ──
|
|
79
78
|
DepInfo("faster_whisper", "faster-whisper", "1.0.0", "stt", "all",
|
|
80
|
-
note="本地语音识别引擎 (
|
|
79
|
+
note="本地语音识别引擎 (需要 C++ 编译)"),
|
|
80
|
+
DepInfo("speech_recognition", "SpeechRecognition", "3.10.0", "stt", "all",
|
|
81
|
+
note="在线语音识别 (Google API,纯 Python 无需编译,Termux 兼容)"),
|
|
81
82
|
|
|
82
83
|
# ── 浏览器自动化 (ChromeDev MCP) ──
|
|
83
84
|
# Playwright 已移除,浏览器自动化统一使用 ChromeDevTools Protocol (MCP)
|
package/package.json
CHANGED
package/requirements.txt
CHANGED
package/web/api_server.py
CHANGED
|
@@ -1219,11 +1219,41 @@ class ApiServer:
|
|
|
1219
1219
|
except Exception as e:
|
|
1220
1220
|
logger.warning(f"vosk 转录失败: {e}")
|
|
1221
1221
|
|
|
1222
|
+
# ── 尝试 SpeechRecognition (Google Web Speech API, 纯 Python 无需编译) ──
|
|
1223
|
+
try:
|
|
1224
|
+
import speech_recognition as sr
|
|
1225
|
+
wav_buf = io.BytesIO(audio_data)
|
|
1226
|
+
try:
|
|
1227
|
+
audio_buf = io.BytesIO(audio_data)
|
|
1228
|
+
from pydub import AudioSegment
|
|
1229
|
+
seg = AudioSegment.from_file(audio_buf, format=audio_format or "webm")
|
|
1230
|
+
seg = seg.set_channels(1).set_frame_rate(16000).set_sample_width(2)
|
|
1231
|
+
seg.export(wav_buf, format="wav")
|
|
1232
|
+
except Exception:
|
|
1233
|
+
wav_buf = io.BytesIO(audio_data)
|
|
1234
|
+
wav_buf.seek(0)
|
|
1235
|
+
recognizer = sr.Recognizer()
|
|
1236
|
+
with sr.AudioFile(wav_buf) as source:
|
|
1237
|
+
audio = recognizer.record(source)
|
|
1238
|
+
text = recognizer.recognize_google(audio, language="zh-CN")
|
|
1239
|
+
if text:
|
|
1240
|
+
logger.info("SpeechRecognition (Google API) 转录成功")
|
|
1241
|
+
return web.json_response({"text": text, "engine": "speech_recognition"})
|
|
1242
|
+
except ImportError:
|
|
1243
|
+
logger.debug("SpeechRecognition 未安装,跳过")
|
|
1244
|
+
except sr.UnknownValueError:
|
|
1245
|
+
logger.debug("SpeechRecognition 无法识别音频内容")
|
|
1246
|
+
except sr.RequestError as e:
|
|
1247
|
+
logger.warning(f"SpeechRecognition API 请求失败: {e}")
|
|
1248
|
+
except Exception as e:
|
|
1249
|
+
logger.warning(f"SpeechRecognition 转录失败: {e}")
|
|
1250
|
+
|
|
1222
1251
|
# ── 没有可用的 STT 引擎 ──
|
|
1223
1252
|
return web.json_response({
|
|
1224
|
-
"error": "未检测到本地 STT
|
|
1225
|
-
" pip install faster-whisper (
|
|
1226
|
-
"
|
|
1253
|
+
"error": "未检测到本地 STT 引擎。请安装以下任一引擎:\n"
|
|
1254
|
+
" pip install faster-whisper (推荐,离线,首次下载模型 ~39MB)\n"
|
|
1255
|
+
" pip install vosk (离线,需下载模型)\n"
|
|
1256
|
+
" pip install SpeechRecognition (在线,使用 Google API,无需编译)",
|
|
1227
1257
|
"available": False,
|
|
1228
1258
|
}, status=503)
|
|
1229
1259
|
|
|
@@ -5559,7 +5589,16 @@ class ApiServer:
|
|
|
5559
5589
|
self._runner = web.AppRunner(self.app)
|
|
5560
5590
|
await self._runner.setup()
|
|
5561
5591
|
site = web.TCPSite(self._runner, host, port)
|
|
5562
|
-
|
|
5592
|
+
try:
|
|
5593
|
+
await site.start()
|
|
5594
|
+
except OSError as e:
|
|
5595
|
+
if e.errno == 98 or "address already in use" in str(e).lower():
|
|
5596
|
+
logger.error(f"端口 {port} 已被占用!")
|
|
5597
|
+
logger.error(f" 可能是上次的 MyAgent 还在运行,请先关闭后再启动")
|
|
5598
|
+
logger.error(f" 或者使用其他端口: myagent-ai web --port 8768")
|
|
5599
|
+
logger.error(f" 查看占用端口的进程: lsof -i :{port} 或 netstat -tlnp | grep {port}")
|
|
5600
|
+
raise SystemExit(1)
|
|
5601
|
+
raise
|
|
5563
5602
|
logger.info(f"管理后台: http://{host}:{port}/ui/")
|
|
5564
5603
|
|
|
5565
5604
|
async def stop(self):
|