feat: support configuration of emotion detection

This commit is contained in:
ed 2025-05-26 16:22:49 +08:00
parent ed144177bf
commit 4e9ec23a74
3 changed files with 6 additions and 3 deletions

View file

@ -60,6 +60,8 @@ enable_greeting: true
enable_stop_tts_notify: false
# 说完话是否开启提示音,音效地址
stop_tts_notify_voice: "config/assets/tts_notify.mp3"
# 是否启用情感检测
enable_emotion_detection: true
exit_commands:
- "退出"

View file

@ -871,8 +871,9 @@ class ConnectionHandler:
if self.stop_event.is_set():
break
continue
enable_emotion_detection = self.config.get("enable_emotion_detection", True)
future = asyncio.run_coroutine_threadsafe(
sendAudioMessage(self, audio_datas, text, text_index), self.loop
sendAudioMessage(self, audio_datas, text, text_index, enable_emotion_detection), self.loop
)
future.result()
except Exception as e:

View file

@ -30,9 +30,9 @@ emoji_map = {
}
async def sendAudioMessage(conn, audios, text, text_index=0):
async def sendAudioMessage(conn, audios, text, text_index=0, enable_emotion_detection=True):
# 发送句子开始消息
if text is not None:
if enable_emotion_detection and text is not None:
emotion = analyze_emotion(text)
emoji = emoji_map.get(emotion, "🙂") # 默认使用笑脸
await conn.websocket.send(