mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
parent
bdee0167f5
commit
fbb3e94d98
2 changed files with 1 additions and 14 deletions
|
|
@ -23,12 +23,6 @@ def get_local_ip():
|
||||||
return local_ip
|
return local_ip
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return "127.0.0.1"
|
return "127.0.0.1"
|
||||||
|
|
||||||
def get_public_ip():
|
|
||||||
try:
|
|
||||||
return requests.get("https://api.ipify.org", timeout=2).text
|
|
||||||
except Exception as e:
|
|
||||||
return "unknown"
|
|
||||||
|
|
||||||
def is_private_ip(ip_addr):
|
def is_private_ip(ip_addr):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import websockets
|
import websockets
|
||||||
import requests
|
|
||||||
from config.logger import setup_logging
|
from config.logger import setup_logging
|
||||||
from core.connection import ConnectionHandler
|
from core.connection import ConnectionHandler
|
||||||
from core.utils.util import get_local_ip
|
from core.utils.util import get_local_ip
|
||||||
from core.utils.util import get_public_ip
|
|
||||||
from core.utils import asr, vad, llm, tts, memory, intent
|
from core.utils import asr, vad, llm, tts, memory, intent
|
||||||
|
|
||||||
TAG = __name__
|
TAG = __name__
|
||||||
|
|
@ -60,7 +58,6 @@ class WebSocketServer:
|
||||||
self.config["Intent"][self.config["selected_module"]["Intent"]]
|
self.config["Intent"][self.config["selected_module"]["Intent"]]
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
server_config = self.config["server"]
|
server_config = self.config["server"]
|
||||||
|
|
@ -69,11 +66,7 @@ class WebSocketServer:
|
||||||
selected_module = self.config.get("selected_module")
|
selected_module = self.config.get("selected_module")
|
||||||
self.logger.bind(tag=TAG).info(f"selected_module values: {', '.join(selected_module.values())}")
|
self.logger.bind(tag=TAG).info(f"selected_module values: {', '.join(selected_module.values())}")
|
||||||
|
|
||||||
public_ip = get_public_ip() # 获取公共 IP
|
self.logger.bind(tag=TAG).info("Server is running at ws://{}:{}", get_local_ip(), port)
|
||||||
local_ip = get_local_ip() # 获取本地 IP
|
|
||||||
|
|
||||||
self.logger.bind(tag=TAG).info("Server is running locally at ws://{}:{}", local_ip, port)
|
|
||||||
self.logger.bind(tag=TAG).info("Server is running publicly at ws://{}:{}", public_ip, port)
|
|
||||||
self.logger.bind(tag=TAG).info("=======上面的地址是websocket协议地址,请勿用浏览器访问=======")
|
self.logger.bind(tag=TAG).info("=======上面的地址是websocket协议地址,请勿用浏览器访问=======")
|
||||||
async with websockets.serve(
|
async with websockets.serve(
|
||||||
self._handle_connection,
|
self._handle_connection,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue