diff --git a/main/xiaozhi-server/core/providers/asr/aliyun_stream.py b/main/xiaozhi-server/core/providers/asr/aliyun_stream.py index 2f16a975..61ba7dc9 100644 --- a/main/xiaozhi-server/core/providers/asr/aliyun_stream.py +++ b/main/xiaozhi-server/core/providers/asr/aliyun_stream.py @@ -84,7 +84,13 @@ class ASRProvider(ASRProviderBase): self.appkey = config.get("appkey") self.token = config.get("token") self.host = config.get("host", "nls-gateway-cn-shanghai.aliyuncs.com") - self.ws_url = f"wss://{self.host}/ws/v1" + # 如果配置的是内网地址(包含-internal.aliyuncs.com),则使用ws协议,默认是wss协议 + if "-internal." in self.host: + self.ws_url = f"ws://{self.host}/ws/v1" + else: + # 默认使用wss协议 + self.ws_url = f"wss://{self.host}/ws/v1" + self.max_sentence_silence = config.get("max_sentence_silence") self.output_dir = config.get("output_dir", "./audio_output") self.delete_audio_file = delete_audio_file diff --git a/main/xiaozhi-server/core/providers/tts/aliyun_stream.py b/main/xiaozhi-server/core/providers/tts/aliyun_stream.py index 0131fcfd..0bfb367b 100644 --- a/main/xiaozhi-server/core/providers/tts/aliyun_stream.py +++ b/main/xiaozhi-server/core/providers/tts/aliyun_stream.py @@ -120,7 +120,12 @@ class TTSProvider(TTSProviderBase): # WebSocket配置 self.host = config.get("host", "nls-gateway-cn-beijing.aliyuncs.com") - self.ws_url = f"wss://{self.host}/ws/v1" + # 如果配置的是内网地址(包含-internal.aliyuncs.com),则使用ws协议,默认是wss协议 + if "-internal." in self.host: + self.ws_url = f"ws://{self.host}/ws/v1" + else: + # 默认使用wss协议 + self.ws_url = f"wss://{self.host}/ws/v1" self.ws = None self._monitor_task = None self.last_active_time = None