mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
update:优化代码
This commit is contained in:
parent
b8051de81d
commit
b8364af0d9
2 changed files with 1 additions and 16 deletions
|
|
@ -44,21 +44,6 @@ async def handleAudioMessage(conn, audio):
|
|||
conn.asr_audio.clear()
|
||||
conn.reset_vad_states()
|
||||
|
||||
async def speechToText(conn):
|
||||
conn.client_abort = False
|
||||
conn.asr_server_receive = False
|
||||
text, file_path = await conn.asr.speech_to_text(conn.asr_audio, conn.session_id)
|
||||
logger.info(f"识别文本: {text}")
|
||||
text_len, text_without_punctuation = remove_punctuation_and_length(text)
|
||||
if text_len <= conn.max_cmd_length and await handleCMDMessage(conn, text_without_punctuation):
|
||||
return
|
||||
if text_len > 0:
|
||||
await startToChat(conn, text)
|
||||
else:
|
||||
conn.asr_server_receive = True
|
||||
conn.asr_audio.clear()
|
||||
conn.reset_vad_states()
|
||||
|
||||
async def handleCMDMessage(conn, text):
|
||||
cmd_exit = conn.cmd_exit
|
||||
for cmd in cmd_exit:
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class TTSProvider(TTSProviderBase):
|
|||
self.channels = config.get("channels",1)
|
||||
self.rate = config.get("rate",44100)
|
||||
self.api_key = config.get("api_key","YOUR_API_KEY")
|
||||
if not self.api_key or "你" in self.api_key:
|
||||
if "你" in self.api_key:
|
||||
logger.bind(tag=TAG).error("你还没配置FishSpeech TTS的密钥,请在配置文件中配置密钥,否则无法正常工作")
|
||||
return
|
||||
self.normalize = config.get("normalize",True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue