add: 部署文件

This commit is contained in:
lizhongxiang 2025-02-27 10:41:51 +08:00
parent f2c78aff23
commit bb81cc149c
3 changed files with 27 additions and 3 deletions

View file

@ -1,6 +1,9 @@
version: '3.8' version: '3.8'
services: services:
esp32-server: esp32-server:
build:
context: ..
dockerfile: Dockerfile
image: 192.168.101.99/yyn/192.168.101.99/yyn/esp32-server:1.0 image: 192.168.101.99/yyn/192.168.101.99/yyn/esp32-server:1.0
container_name: esp32-server container_name: esp32-server
restart: always restart: always

View file

@ -152,7 +152,7 @@ async def sendAudioMessageStream(conn, audios_queue, duration, text):
if last_duration <= 0 : if last_duration <= 0 :
last_duration = 0 last_duration = 0
opus_datas, duration = conn.tts.wav_to_opus_data_audio(audio_data_chunke_data) opus_datas, duration = conn.tts.wav_to_opus_data_audio(audio_data_chunke_data)
conn.tts_duration = duration + last_duration conn.tts_duration = duration + last_duration + 0.5
for opus_packet in opus_datas: for opus_packet in opus_datas:
await conn.websocket.send(opus_packet) await conn.websocket.send(opus_packet)
print(f"已获取音频数据,长度为 {len(audio_data_chunke_data)},总长度为 {len(audio_data_chunke_data)}") print(f"已获取音频数据,长度为 {len(audio_data_chunke_data)},总长度为 {len(audio_data_chunke_data)}")
@ -162,14 +162,14 @@ async def sendAudioMessageStream(conn, audios_queue, duration, text):
traceback.print_exc() # 打印错误堆栈 traceback.print_exc() # 打印错误堆栈
if conn.llm_finish_task and text == conn.tts_last_text: if conn.llm_finish_task and text == conn.tts_last_text:
stop_duration = conn.tts_duration stop_duration = conn.tts_duration + 0.5
stop_task = asyncio.create_task( stop_task = asyncio.create_task(
schedule_with_interrupt(stop_duration, send_tts_stop(conn, text)) schedule_with_interrupt(stop_duration, send_tts_stop(conn, text))
) )
conn.scheduled_tasks.append(stop_task) conn.scheduled_tasks.append(stop_task)
async def sendAudioMessage(conn, audios, duration, text): async def sendAudioMessage(conn, audios, duration, text):
base_delay = conn.tts_duration+0.5 base_delay = conn.tts_duration
if text == conn.tts_first_text: if text == conn.tts_first_text:
conn.tts_start_speak_time = time.time() conn.tts_start_speak_time = time.time()

21
deploy.sh Normal file
View file

@ -0,0 +1,21 @@
#!/bin/bash
set -x
set -e
COMPOSE_DIR='compose-config'
server_no=$(ifconfig eno1 | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | awk -F. '{print $4}')
compose_file="${COMPOSE_DIR}/${APP_ENV}-${server_no}-docker-compose.yml"
#判断compose_file是否存在,如果不存在echo后-退出-说明
if [ ! -f "$compose_file" ]; then
echo "Error: Compose file '$compose_file' not found. Exiting."
exit 1
fi
echo "Exute compose file: '$compose_file'."
echo "git pull"
git pull
docker compose -f ${compose_file} up -d --build
sleep 3
docker logs -f -n 30 esp32-server