From 55d66e2cc7c98839f428a6dd2567de8a54dc9b54 Mon Sep 17 00:00:00 2001 From: whosmyqueen <644049260@qq.com> Date: Mon, 28 Apr 2025 13:38:26 +0800 Subject: [PATCH 1/9] =?UTF-8?q?feat(core):=20=E6=B7=BB=E5=8A=A0=20FunASR?= =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E8=AF=86=E5=88=AB=E6=8F=90=E4=BE=9B=E5=95=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 FunASR 语音识别服务器的实现类 ASRProvider - 实现了 Opus 音频数据的解码和 PCM 数据的发送- 添加了 WebSocket 通信的逻辑,包括发送配置信息、音频数据和接收响应 - 集成了日志记录和错误处理功能 --- .../core/providers/asr/fun_server.py | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 main/xiaozhi-server/core/providers/asr/fun_server.py diff --git a/main/xiaozhi-server/core/providers/asr/fun_server.py b/main/xiaozhi-server/core/providers/asr/fun_server.py new file mode 100644 index 000000000..0298f039d --- /dev/null +++ b/main/xiaozhi-server/core/providers/asr/fun_server.py @@ -0,0 +1,146 @@ +from typing import Optional, Tuple, List +import opuslib_next +from core.providers.asr.base import ASRProviderBase +import ssl +import json +import websockets +from config.logger import setup_logging +import asyncio + +TAG = __name__ +logger = setup_logging() + + +class ASRProvider(ASRProviderBase): + def __init__(self, config: dict, delete_audio_file: bool): + ''' + Initialize the ASRProvider with server configuration. + :param config: Dictionary containing 'host', 'port', and 'is_ssl'. + :param delete_audio_file: Boolean to indicate whether to delete audio files after processing. + ''' + self.host = config.get('host', 'localhost') + self.port = config.get('port', 10095) + self.api_key = config.get('api_key', 'none') + self.is_ssl = config.get('is_ssl', True) + self.delete_audio_file = delete_audio_file + self.uri = f"wss://{self.host}:{self.port}" if self.is_ssl else f"ws://{self.host}:{self.port}" + self.ssl_context = ssl.SSLContext() if self.is_ssl else None + if self.ssl_context: + self.ssl_context.check_hostname = False + self.ssl_context.verify_mode = ssl.CERT_NONE + + def save_audio_to_file(self, opus_data: List[bytes], session_id: str) -> str: + """解码Opus数据并保存为WAV文件""" + pass + + @staticmethod + def decode_opus(opus_data: List[bytes]) -> bytes: + """将Opus音频数据解码为PCM数据""" + decoder = opuslib_next.Decoder(16000, 1) # 16kHz, 单声道 + pcm_data = [] + + for opus_packet in opus_data: + try: + pcm_frame = decoder.decode(opus_packet, 960) # 960 samples = 60ms + pcm_data.append(pcm_frame) + except opuslib_next.OpusError as e: + logger.bind(tag=TAG).error(f"Opus解码错误: {e}", exc_info=True) + + return b"".join(pcm_data) + + async def _receive_responses(self, ws) -> None: + ''' + Asynchronous generator to receive messages from the WebSocket. + Yields each message as it is received. + ''' + text = "" + while True: + try: + response = await asyncio.wait_for(ws.recv(), timeout=5) + response_data = json.loads(response) + logger.bind(tag=TAG).debug(f"Received response: {response_data}") + if response_data.get("is_final", True): + text += response_data.get("text", "") + break + else: + text += response_data.get("text", "") + except asyncio.TimeoutError: + logger.bind(tag=TAG).error("Timeout while waiting for response from WebSocket.") + break + except websockets.exceptions.ConnectionClosed as e: + logger.bind(tag=TAG).error(f"WebSocket connection closed: {e}") + break + return text + + async def _send_data(self, ws, pcm_data: bytes, session_id: str) -> tuple: + ''' + Internal method to handle WebSocket communication. + Reuses the persistent WebSocket connection if available. + :param pcm_data: PCM audio data to send. + :param session_id: Unique session identifier. + :return: Tuple containing recognized text and optional timestamp. + ''' + + # Send initial configuration message + config_message = json.dumps({ + "mode": "offline", + "chunk_size": [5, 10, 5], + "chunk_interval": 10, + "wav_name": session_id, + "is_speaking": True, + "itn": False + }) + await ws.send(config_message) + logger.bind(tag=TAG).debug(f"Sent configuration message: {config_message}") + + # Send PCM data + await ws.send(pcm_data) + logger.bind(tag=TAG).debug(f"Sent PCM data of length: {len(pcm_data)} bytes") + + # Indicate end of speech + end_message = json.dumps({"is_speaking": False}) + await ws.send(end_message) + logger.bind(tag=TAG).debug(f"Sent end message: {end_message}") + + async def speech_to_text(self, opus_data: List[bytes], session_id: str) -> Tuple[Optional[str], Optional[str]]: + ''' + Convert speech data to text using FunASR. + :param opus_data: List of Opus-encoded audio data chunks. + :param session_id: Unique session identifier. + :return: Tuple containing recognized text and optional timestamp. + ''' + + pcm_data = self.decode_opus(opus_data) + auth_header = {'Authorization': 'Bearer; {}'.format(self.api_key)} + async with websockets.connect(self.uri, additional_headers=auth_header, subprotocols=["binary"], ping_interval=None, + ssl=self.ssl_context) as ws: + try: + # Use asyncio to handle WebSocket communication + send_task = asyncio.create_task(self._send_data(ws, pcm_data, session_id)) + receive_task = asyncio.create_task(self._receive_responses(ws)) + + # Gather tasks with error handling + done, pending = await asyncio.wait( + [send_task, receive_task], + return_when=asyncio.FIRST_EXCEPTION + ) + + # Cancel any pending tasks + for task in pending: + task.cancel() + + # Check for exceptions in completed tasks + for task in done: + if task.exception(): + raise task.exception() + + # Get the result from the receive task + result = receive_task.result() + return result, None # Return the recognized text and timestamp (if any) + + except websockets.exceptions.ConnectionClosed as e: + logger.bind(tag=TAG).error(f"WebSocket connection closed: {e}") + return "", None + except Exception as e: + logger.bind(tag=TAG).error(f"Error during speech-to-text conversion: {e}", exc_info=True) + return "", None From 5790ec837e1a2701fdc4dfff5fe8ef044b2f577a Mon Sep 17 00:00:00 2001 From: whosmyqueen <644049260@qq.com> Date: Mon, 28 Apr 2025 17:31:22 +0800 Subject: [PATCH 2/9] =?UTF-8?q?fix(core):=20=E4=BF=AE=E5=A4=8D=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E8=AF=86=E5=88=AB=E7=BB=93=E6=9E=9C=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 ASRProvider 的 receive 方法中添加正则匹配,过滤掉不必要的前缀信息- 优化了语音识别结果的处理流程,提高了结果的准确性和可用性 --- main/xiaozhi-server/core/providers/asr/fun_server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main/xiaozhi-server/core/providers/asr/fun_server.py b/main/xiaozhi-server/core/providers/asr/fun_server.py index 0298f039d..b27827de0 100644 --- a/main/xiaozhi-server/core/providers/asr/fun_server.py +++ b/main/xiaozhi-server/core/providers/asr/fun_server.py @@ -1,3 +1,4 @@ +import re from typing import Optional, Tuple, List import opuslib_next from core.providers.asr.base import ASRProviderBase @@ -136,6 +137,9 @@ class ASRProvider(ASRProviderBase): # Get the result from the receive task result = receive_task.result() + match = re.match(r'<\|(.*?)\|><\|(.*?)\|><\|(.*?)\|>(.*)', result) + if match: + result = match.group(4).strip() return result, None # Return the recognized text and timestamp (if any) except websockets.exceptions.ConnectionClosed as e: From 01fdd34e48e0440f784a6ba00bbef108105dee37 Mon Sep 17 00:00:00 2001 From: whosmyqueen <644049260@qq.com> Date: Mon, 28 Apr 2025 18:07:11 +0800 Subject: [PATCH 3/9] =?UTF-8?q?build(server):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E9=95=9C=E5=83=8F=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新 docker-compose_all.yml 中的服务器镜像地址 - 在 Dockerfile-server 中添加阿里云镜像源以加速国内构建 --- Dockerfile-server | 3 ++- main/xiaozhi-server/docker-compose_all.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile-server b/Dockerfile-server index 7eb771145..ab2c04a04 100644 --- a/Dockerfile-server +++ b/Dockerfile-server @@ -12,7 +12,8 @@ RUN pip install --no-cache-dir -r requirements.txt FROM python:3.10-slim WORKDIR /opt/xiaozhi-esp32-server - +# if you located in China, you can use aliyun mirror to speed up +RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources # 安装系统依赖 RUN apt-get update && \ apt-get install -y --no-install-recommends libopus0 ffmpeg && \ diff --git a/main/xiaozhi-server/docker-compose_all.yml b/main/xiaozhi-server/docker-compose_all.yml index 919101204..f95bb1cb6 100644 --- a/main/xiaozhi-server/docker-compose_all.yml +++ b/main/xiaozhi-server/docker-compose_all.yml @@ -4,7 +4,7 @@ version: '3' services: # Server模块 xiaozhi-esp32-server: - image: ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:server_latest + image: sensetime.com/senseflow/senseflow-esp32-server:server_last container_name: xiaozhi-esp32-server depends_on: - xiaozhi-esp32-server-db From 2fe8d8d490566726815473d782977dcf96be584b Mon Sep 17 00:00:00 2001 From: whosmyqueen <644049260@qq.com> Date: Mon, 28 Apr 2025 19:35:53 +0800 Subject: [PATCH 4/9] =?UTF-8?q?build(Dockerfile-server):=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E9=98=BF=E9=87=8C=E4=BA=91=E9=95=9C=E5=83=8F=E6=BA=90?= =?UTF-8?q?=E5=8A=A0=E9=80=9F=E5=9B=BD=E5=86=85=E6=9E=84=E5=BB=BA-=20?= =?UTF-8?q?=E5=9C=A8=20Python=20=E4=BE=9D=E8=B5=96=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E9=98=BF=E9=87=8C=E4=BA=91=20PyPI?= =?UTF-8?q?=20=E9=95=9C=E5=83=8F=E6=BA=90=20-=20=E6=9B=B4=E6=96=B0=20APT?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E6=BA=90=E4=B8=BA=E9=98=BF=E9=87=8C=E4=BA=91?= =?UTF-8?q?=20Debian=E9=95=9C=E5=83=8F=E6=BA=90=20-=20=E9=80=82=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E5=9C=A8=E5=9B=BD=E5=86=85=E7=8E=AF=E5=A2=83=E4=B8=8B?= =?UTF-8?q?=E5=8A=A0=E9=80=9F=E9=95=9C=E5=83=8F=E6=9E=84=E5=BB=BA=E8=BF=87?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-server | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile-server b/Dockerfile-server index ab2c04a04..0bce8fbd0 100644 --- a/Dockerfile-server +++ b/Dockerfile-server @@ -6,14 +6,16 @@ WORKDIR /app COPY main/xiaozhi-server/requirements.txt . # 安装Python依赖 -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple # 第二阶段:生产镜像 FROM python:3.10-slim WORKDIR /opt/xiaozhi-esp32-server + # if you located in China, you can use aliyun mirror to speed up RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources + # 安装系统依赖 RUN apt-get update && \ apt-get install -y --no-install-recommends libopus0 ffmpeg && \ From 795432c47c2a93dbfb87579ee96daa5bb1af26c8 Mon Sep 17 00:00:00 2001 From: whosmyqueen <644049260@qq.com> Date: Mon, 28 Apr 2025 19:39:22 +0800 Subject: [PATCH 5/9] =?UTF-8?q?build(xiaozhi-esp32-server-db):=20=E5=B0=86?= =?UTF-8?q?=20MySQL=E9=95=9C=E5=83=8F=E7=89=88=E6=9C=AC=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E4=B8=BA=208.4.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 docker-compose_all.yml 文件中 xiaozhi-esp32-server-db服务的镜像版本 -从使用最新版本 (latest)改为使用特定版本 (8.4.5) - 这样做可以确保环境一致性,避免由于 MySQL 升级导致的潜在兼容性问题 --- main/xiaozhi-server/docker-compose_all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/xiaozhi-server/docker-compose_all.yml b/main/xiaozhi-server/docker-compose_all.yml index f95bb1cb6..68b11c0f0 100644 --- a/main/xiaozhi-server/docker-compose_all.yml +++ b/main/xiaozhi-server/docker-compose_all.yml @@ -52,7 +52,7 @@ services: - ./uploadfile:/app/uploadfile xiaozhi-esp32-server-db: - image: mysql:latest + image: mysql:8.4.5 container_name: xiaozhi-esp32-server-db healthcheck: test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] From 83c7a7e79e34049b26f27afeb98781c5bc7c0cb8 Mon Sep 17 00:00:00 2001 From: whosmyqueen <644049260@qq.com> Date: Tue, 29 Apr 2025 14:44:29 +0800 Subject: [PATCH 6/9] =?UTF-8?q?feat(model):=20=E6=B7=BB=E5=8A=A0=20FunASR?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=AF=E8=AF=AD=E9=9F=B3=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在模型供应商中添加 FunASR服务端语音识别模型 - 在模型配置中添加 FunASR服务端语音识别的配置项- 更新 FunASR 本地语音识别模型的名称 --- .../src/main/resources/db/changelog/202504082211.sql | 4 ++-- .../src/main/resources/db/changelog/202504112044.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main/manager-api/src/main/resources/db/changelog/202504082211.sql b/main/manager-api/src/main/resources/db/changelog/202504082211.sql index 91ce33ffc..90ddf14d8 100644 --- a/main/manager-api/src/main/resources/db/changelog/202504082211.sql +++ b/main/manager-api/src/main/resources/db/changelog/202504082211.sql @@ -7,10 +7,10 @@ INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `f ('SYSTEM_VAD_SileroVAD', 'VAD', 'silero', 'SileroVAD语音活动检测', '[{"key":"threshold","label":"检测阈值","type":"number"},{"key":"model_dir","label":"模型目录","type":"string"},{"key":"min_silence_duration_ms","label":"最小静音时长","type":"number"}]', 1, 1, NOW(), 1, NOW()), -- ASR模型供应器 -('SYSTEM_ASR_FunASR', 'ASR', 'fun_local', 'FunASR语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 1, 1, NOW(), 1, NOW()), +('SYSTEM_ASR_FunASR', 'ASR', 'fun_local', 'FunASR本地语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 1, 1, NOW(), 1, NOW()), ('SYSTEM_ASR_SherpaASR', 'ASR', 'sherpa_onnx_local', 'SherpaASR语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 2, 1, NOW(), 1, NOW()), ('SYSTEM_ASR_DoubaoASR', 'ASR', 'doubao', '火山引擎语音识别', '[{"key":"appid","label":"应用ID","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"cluster","label":"集群","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 3, 1, NOW(), 1, NOW()), - +('SYSTEM_ASR_FunASRServer', 'ASR', 'fun_server', 'FunASR服务语音识别', '[{"key":"host","label":"服务地址","type":"string"},{"key":"port","label":"端口号","type":"number"},{"key":"api_key","label":"API密钥","type":"string"},]', 4, 1, NOW(), 1, NOW()), -- LLM模型供应器 ('SYSTEM_LLM_openai', 'LLM', 'openai', 'OpenAI接口', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"model_name","label":"模型名称","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"temperature","label":"温度","type":"number"},{"key":"max_tokens","label":"最大令牌数","type":"number"},{"key":"top_p","label":"top_p值","type":"number"},{"key":"top_k","label":"top_k值","type":"number"},{"key":"frequency_penalty","label":"频率惩罚","type":"number"}]', 1, 1, NOW(), 1, NOW()), ('SYSTEM_LLM_AliBL', 'LLM', 'AliBL', '阿里百炼接口', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"app_id","label":"应用ID","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"is_no_prompt","label":"是否不使用本地prompt","type":"boolean"},{"key":"ali_memory_id","label":"记忆ID","type":"string"}]', 2, 1, NOW(), 1, NOW()), diff --git a/main/manager-api/src/main/resources/db/changelog/202504112044.sql b/main/manager-api/src/main/resources/db/changelog/202504112044.sql index 9fd2257da..2c386d5fb 100644 --- a/main/manager-api/src/main/resources/db/changelog/202504112044.sql +++ b/main/manager-api/src/main/resources/db/changelog/202504112044.sql @@ -7,11 +7,11 @@ DELETE FROM `ai_model_config`; INSERT INTO `ai_model_config` VALUES ('VAD_SileroVAD', 'VAD', 'SileroVAD', '语音活动检测', 1, 1, '{\"type\": \"silero\", \"model_dir\": \"models/snakers4_silero-vad\", \"threshold\": 0.5, \"min_silence_duration_ms\": 700}', NULL, NULL, 1, NULL, NULL, NULL, NULL); -- ASR模型配置 -INSERT INTO `ai_model_config` VALUES ('ASR_FunASR', 'ASR', 'FunASR', 'FunASR语音识别', 1, 1, '{\"type\": \"fun_local\", \"model_dir\": \"models/SenseVoiceSmall\", \"output_dir\": \"tmp/\"}', NULL, NULL, 1, NULL, NULL, NULL, NULL); +INSERT INTO `ai_model_config` VALUES ('ASR_FunASR', 'ASR', 'FunASR', 'FunASR本地语音识别', 1, 1, '{\"type\": \"fun_local\", \"model_dir\": \"models/SenseVoiceSmall\", \"output_dir\": \"tmp/\"}', NULL, NULL, 1, NULL, NULL, NULL, NULL); INSERT INTO `ai_model_config` VALUES ('ASR_SherpaASR', 'ASR', 'SherpaASR', 'Sherpa语音识别', 0, 1, '{\"type\": \"sherpa_onnx_local\", \"model_dir\": \"models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17\", \"output_dir\": \"tmp/\"}', NULL, NULL, 2, NULL, NULL, NULL, NULL); INSERT INTO `ai_model_config` VALUES ('ASR_DoubaoASR', 'ASR', 'DoubaoASR', '豆包语音识别', 0, 1, '{\"type\": \"doubao\", \"appid\": \"\", \"access_token\": \"\", \"cluster\": \"volcengine_input_common\", \"output_dir\": \"tmp/\"}', NULL, NULL, 3, NULL, NULL, NULL, NULL); INSERT INTO `ai_model_config` VALUES ('ASR_TencentASR', 'ASR', 'TencentASR', '腾讯语音识别', 0, 1, '{\"type\": \"tencent\", \"appid\": \"\", \"secret_id\": \"\", \"secret_key\": \"你的secret_key\", \"output_dir\": \"tmp/\"}', NULL, NULL, 4, NULL, NULL, NULL, NULL); - +INSERT INTO `ai_model_config` VALUES ('ASR_FunASRServer', 'ASR', 'FunASRServer', 'FunASR服务语音识别', 0, 1, '{\"type\": \"fun_server\", \"host\": \"127.0.0.1\", \"port\": 10096, \"api_key\": \"\"}', NULL, NULL, 5, NULL, NULL, NULL, NULL); -- LLM模型配置 INSERT INTO `ai_model_config` VALUES ('LLM_ChatGLMLLM', 'LLM', 'ChatGLMLLM', '智谱AI', 1, 1, '{\"type\": \"openai\", \"model_name\": \"glm-4-flash\", \"base_url\": \"https://open.bigmodel.cn/api/paas/v4/\", \"api_key\": \"你的api_key\"}', NULL, NULL, 1, NULL, NULL, NULL, NULL); INSERT INTO `ai_model_config` VALUES ('LLM_OllamaLLM', 'LLM', 'OllamaLLM', 'Ollama本地模型', 0, 1, '{\"type\": \"ollama\", \"model_name\": \"qwen2.5\", \"base_url\": \"http://localhost:11434\"}', NULL, NULL, 2, NULL, NULL, NULL, NULL); From 0948ea62e085172368d58bd54649980041e6d7d9 Mon Sep 17 00:00:00 2001 From: whosmyqueen <644049260@qq.com> Date: Tue, 29 Apr 2025 14:47:25 +0800 Subject: [PATCH 7/9] =?UTF-8?q?build(Dockerfile-web):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91=E9=95=9C=E5=83=8F=E6=BA=90=E4=BB=A5?= =?UTF-8?q?=E5=8A=A0=E9=80=9F=E5=9B=BD=E5=86=85=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 Dockerfile-web 中添加了阿里云 Debian 镜像源 - 通过修改 /etc/apt/sources.list.d/debian.sources 文件实现镜像源替换 -此修改旨在提高国内用户的构建速度 --- Dockerfile-web | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile-web b/Dockerfile-web index 9e5da6787..31995c7d9 100644 --- a/Dockerfile-web +++ b/Dockerfile-web @@ -16,6 +16,9 @@ RUN mvn clean package -Dmaven.test.skip=true # 第三阶段:构建最终镜像 FROM eclipse-temurin:21-jdk-jammy +# if you located in China, you can use aliyun mirror to speed up +RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources + # 安装Nginx并清理缓存 RUN apt-get update && \ apt-get install -y nginx && \ From b816273a2c77a3f82d622aadc861691f598f485d Mon Sep 17 00:00:00 2001 From: whosmyqueen <644049260@qq.com> Date: Tue, 29 Apr 2025 14:50:30 +0800 Subject: [PATCH 8/9] =?UTF-8?q?build(Dockerfile-web):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91=E9=95=9C=E5=83=8F=E6=BA=90=E9=85=8D?= =?UTF-8?q?=E7=BD=AE-=20=E5=88=A0=E9=99=A4=E4=BA=86=20Dockerfile=20?= =?UTF-8?q?=E4=B8=AD=E9=92=88=E5=AF=B9=E4=B8=AD=E5=9B=BD=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=9A=84=E9=98=BF=E9=87=8C=E4=BA=91=E9=95=9C=E5=83=8F=E6=BA=90?= =?UTF-8?q?=E9=85=8D=E7=BD=AE-=20=E4=BF=9D=E7=95=99=E4=BA=86=E5=AE=89?= =?UTF-8?q?=E8=A3=85=20Nginx=20=E5=B9=B6=E6=B8=85=E7=90=86=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-web | 3 --- 1 file changed, 3 deletions(-) diff --git a/Dockerfile-web b/Dockerfile-web index 31995c7d9..9e5da6787 100644 --- a/Dockerfile-web +++ b/Dockerfile-web @@ -16,9 +16,6 @@ RUN mvn clean package -Dmaven.test.skip=true # 第三阶段:构建最终镜像 FROM eclipse-temurin:21-jdk-jammy -# if you located in China, you can use aliyun mirror to speed up -RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources - # 安装Nginx并清理缓存 RUN apt-get update && \ apt-get install -y nginx && \ From 10e3e18004fac6e8d49329004518b7bf26b310e8 Mon Sep 17 00:00:00 2001 From: whosmyqueen <644049260@qq.com> Date: Tue, 29 Apr 2025 15:04:54 +0800 Subject: [PATCH 9/9] =?UTF-8?q?fix(database):=20=E4=BF=AE=E5=A4=8D=20FunAS?= =?UTF-8?q?R=20=E6=9C=8D=E5=8A=A1=E9=85=8D=E7=BD=AE=E7=9A=84=20JSON=20?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在数据库变更脚本中修正了 FunASR 服务配置的 JSON 字符串 - 删除了多余的逗号,确保 JSON 格式正确 -简化了 API 密钥的默认值,从空字符串改为 "none" --- .../src/main/resources/db/changelog/202504082211.sql | 2 +- .../src/main/resources/db/changelog/202504112044.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/manager-api/src/main/resources/db/changelog/202504082211.sql b/main/manager-api/src/main/resources/db/changelog/202504082211.sql index 90ddf14d8..c4825c3e8 100644 --- a/main/manager-api/src/main/resources/db/changelog/202504082211.sql +++ b/main/manager-api/src/main/resources/db/changelog/202504082211.sql @@ -10,7 +10,7 @@ INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `f ('SYSTEM_ASR_FunASR', 'ASR', 'fun_local', 'FunASR本地语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 1, 1, NOW(), 1, NOW()), ('SYSTEM_ASR_SherpaASR', 'ASR', 'sherpa_onnx_local', 'SherpaASR语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 2, 1, NOW(), 1, NOW()), ('SYSTEM_ASR_DoubaoASR', 'ASR', 'doubao', '火山引擎语音识别', '[{"key":"appid","label":"应用ID","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"cluster","label":"集群","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 3, 1, NOW(), 1, NOW()), -('SYSTEM_ASR_FunASRServer', 'ASR', 'fun_server', 'FunASR服务语音识别', '[{"key":"host","label":"服务地址","type":"string"},{"key":"port","label":"端口号","type":"number"},{"key":"api_key","label":"API密钥","type":"string"},]', 4, 1, NOW(), 1, NOW()), +('SYSTEM_ASR_FunASRServer', 'ASR', 'fun_server', 'FunASR服务语音识别', '[{"key":"host","label":"服务地址","type":"string"},{"key":"port","label":"端口号","type":"number"},{"key":"api_key","label":"API密钥","type":"string"}]', 4, 1, NOW(), 1, NOW()), -- LLM模型供应器 ('SYSTEM_LLM_openai', 'LLM', 'openai', 'OpenAI接口', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"model_name","label":"模型名称","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"temperature","label":"温度","type":"number"},{"key":"max_tokens","label":"最大令牌数","type":"number"},{"key":"top_p","label":"top_p值","type":"number"},{"key":"top_k","label":"top_k值","type":"number"},{"key":"frequency_penalty","label":"频率惩罚","type":"number"}]', 1, 1, NOW(), 1, NOW()), ('SYSTEM_LLM_AliBL', 'LLM', 'AliBL', '阿里百炼接口', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"app_id","label":"应用ID","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"is_no_prompt","label":"是否不使用本地prompt","type":"boolean"},{"key":"ali_memory_id","label":"记忆ID","type":"string"}]', 2, 1, NOW(), 1, NOW()), diff --git a/main/manager-api/src/main/resources/db/changelog/202504112044.sql b/main/manager-api/src/main/resources/db/changelog/202504112044.sql index 2c386d5fb..f4d7d9595 100644 --- a/main/manager-api/src/main/resources/db/changelog/202504112044.sql +++ b/main/manager-api/src/main/resources/db/changelog/202504112044.sql @@ -11,7 +11,7 @@ INSERT INTO `ai_model_config` VALUES ('ASR_FunASR', 'ASR', 'FunASR', 'FunASR本 INSERT INTO `ai_model_config` VALUES ('ASR_SherpaASR', 'ASR', 'SherpaASR', 'Sherpa语音识别', 0, 1, '{\"type\": \"sherpa_onnx_local\", \"model_dir\": \"models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17\", \"output_dir\": \"tmp/\"}', NULL, NULL, 2, NULL, NULL, NULL, NULL); INSERT INTO `ai_model_config` VALUES ('ASR_DoubaoASR', 'ASR', 'DoubaoASR', '豆包语音识别', 0, 1, '{\"type\": \"doubao\", \"appid\": \"\", \"access_token\": \"\", \"cluster\": \"volcengine_input_common\", \"output_dir\": \"tmp/\"}', NULL, NULL, 3, NULL, NULL, NULL, NULL); INSERT INTO `ai_model_config` VALUES ('ASR_TencentASR', 'ASR', 'TencentASR', '腾讯语音识别', 0, 1, '{\"type\": \"tencent\", \"appid\": \"\", \"secret_id\": \"\", \"secret_key\": \"你的secret_key\", \"output_dir\": \"tmp/\"}', NULL, NULL, 4, NULL, NULL, NULL, NULL); -INSERT INTO `ai_model_config` VALUES ('ASR_FunASRServer', 'ASR', 'FunASRServer', 'FunASR服务语音识别', 0, 1, '{\"type\": \"fun_server\", \"host\": \"127.0.0.1\", \"port\": 10096, \"api_key\": \"\"}', NULL, NULL, 5, NULL, NULL, NULL, NULL); +INSERT INTO `ai_model_config` VALUES ('ASR_FunASRServer', 'ASR', 'FunASRServer', 'FunASR服务语音识别', 0, 1, '{\"type\":\"fun_server\",\"host\":\"127.0.0.1\",\"port\":10096,\"api_key\":\"none\"}', NULL, NULL, 5, NULL, NULL, NULL, NULL); -- LLM模型配置 INSERT INTO `ai_model_config` VALUES ('LLM_ChatGLMLLM', 'LLM', 'ChatGLMLLM', '智谱AI', 1, 1, '{\"type\": \"openai\", \"model_name\": \"glm-4-flash\", \"base_url\": \"https://open.bigmodel.cn/api/paas/v4/\", \"api_key\": \"你的api_key\"}', NULL, NULL, 1, NULL, NULL, NULL, NULL); INSERT INTO `ai_model_config` VALUES ('LLM_OllamaLLM', 'LLM', 'OllamaLLM', 'Ollama本地模型', 0, 1, '{\"type\": \"ollama\", \"model_name\": \"qwen2.5\", \"base_url\": \"http://localhost:11434\"}', NULL, NULL, 2, NULL, NULL, NULL, NULL);