fix: 优化

This commit is contained in:
Sakura-RanChen
2025-09-02 14:34:26 +08:00
parent c3c2e7c28e
commit b9df6d4ad2
3 changed files with 54 additions and 14 deletions
@@ -3,7 +3,7 @@ import json
import random
import asyncio
from core.utils.dialogue import Message
from core.utils.util import audio_to_data_stream
from core.utils.util import audio_to_data
from core.providers.tts.dto.dto import SentenceType
from core.utils.wakeup_word import WakeupWordsConfig
from core.handle.sendAudioHandle import sendAudioMessage, send_stt_message
@@ -91,12 +91,7 @@ async def checkWakeupWords(conn, text):
}
# 获取音频数据
opus_packets = []
def handle_audio_frame(frame_data):
opus_packets.append(frame_data)
audio_to_data_stream(response.get("file_path"), is_opus=True, callback=handle_audio_frame)
opus_packets = audio_to_data(response.get("file_path"))
# 播放唤醒词回复
conn.client_abort = False
@@ -2,7 +2,7 @@ import json
import time
import asyncio
from core.utils import textUtils
from core.utils.util import audio_to_data_stream
from core.utils.util import audio_to_data
from core.providers.tts.dto.dto import SentenceType
TAG = __name__
@@ -120,12 +120,7 @@ async def send_tts_message(conn, state, text=None):
stop_tts_notify_voice = conn.config.get(
"stop_tts_notify_voice", "config/assets/tts_notify.mp3"
)
# 获取音频数据
audios = []
def handle_audio_frame(frame_data):
audios.append(frame_data)
audio_to_data_stream(stop_tts_notify_voice, is_opus=True, callback=handle_audio_frame)
audios = audio_to_data(stop_tts_notify_voice, is_opus=True)
await sendAudio(conn, audios)
# 清除服务端讲话状态
conn.clearSpeakStatus()