修复一些问题, 添加缺失的TTS_ENABLE
This commit is contained in:
26
cli.py
26
cli.py
@@ -25,6 +25,7 @@ TEMPERATURE = config.FindItem("temperature", 1.3)
|
|||||||
MAX_CONTENT_LENGTH = config.FindItem("max_content_length", None)
|
MAX_CONTENT_LENGTH = config.FindItem("max_content_length", None)
|
||||||
SYSTEM_PROMPT_PATH = config.FindItem("system_prompt_path", None)
|
SYSTEM_PROMPT_PATH = config.FindItem("system_prompt_path", None)
|
||||||
AUTO_SPEAK_WAIT_SECOND = config.FindItem("auto_speak_wait_second", 15.0)
|
AUTO_SPEAK_WAIT_SECOND = config.FindItem("auto_speak_wait_second", 15.0)
|
||||||
|
TTS_ENABLE = config.FindItem("tts_enable", False)
|
||||||
TTS_SERVER_URL = config.FindItem("tts_server_url", "http://localhost:43400")
|
TTS_SERVER_URL = config.FindItem("tts_server_url", "http://localhost:43400")
|
||||||
TTS_PROMPT_TEXT = config.FindItem("tts_prompt_text", None)
|
TTS_PROMPT_TEXT = config.FindItem("tts_prompt_text", None)
|
||||||
TTS_PROMPT_WAV_PATH = config.FindItem("tts_prompt_wav_path", None)
|
TTS_PROMPT_WAV_PATH = config.FindItem("tts_prompt_wav_path", None)
|
||||||
@@ -40,6 +41,7 @@ if VERBOSE:
|
|||||||
PrintColorful(ConsoleFrontColor.LIGHTYELLOW_EX,f"MAX_CONTENT_LENGTH: {MAX_CONTENT_LENGTH}")
|
PrintColorful(ConsoleFrontColor.LIGHTYELLOW_EX,f"MAX_CONTENT_LENGTH: {MAX_CONTENT_LENGTH}")
|
||||||
PrintColorful(ConsoleFrontColor.LIGHTYELLOW_EX,f"SYSTEM_PROMPT_PATH: {SYSTEM_PROMPT_PATH}")
|
PrintColorful(ConsoleFrontColor.LIGHTYELLOW_EX,f"SYSTEM_PROMPT_PATH: {SYSTEM_PROMPT_PATH}")
|
||||||
PrintColorful(ConsoleFrontColor.LIGHTYELLOW_EX,f"AUTO_SPEAK_WAIT_SECOND: {AUTO_SPEAK_WAIT_SECOND}")
|
PrintColorful(ConsoleFrontColor.LIGHTYELLOW_EX,f"AUTO_SPEAK_WAIT_SECOND: {AUTO_SPEAK_WAIT_SECOND}")
|
||||||
|
PrintColorful(ConsoleFrontColor.LIGHTYELLOW_EX,f"TTS_ENABLE: {TTS_ENABLE}")
|
||||||
temp_dir = config.GetFile("temp")|chat_start_id|None
|
temp_dir = config.GetFile("temp")|chat_start_id|None
|
||||||
|
|
||||||
ollama_llm_config = {
|
ollama_llm_config = {
|
||||||
@@ -202,6 +204,8 @@ async def audio_player_worker():
|
|||||||
|
|
||||||
# CHANGE TOCHECK
|
# CHANGE TOCHECK
|
||||||
async def play_vocal(text:str) -> None:
|
async def play_vocal(text:str) -> None:
|
||||||
|
if not TTS_ENABLE:
|
||||||
|
return
|
||||||
if len(text) == 0 or not text:
|
if len(text) == 0 or not text:
|
||||||
return
|
return
|
||||||
tts_server_url = f"{TTS_SERVER_URL}/api/synthesis/sft"
|
tts_server_url = f"{TTS_SERVER_URL}/api/synthesis/sft"
|
||||||
@@ -287,11 +291,13 @@ async def achat(engine:SimpleChatEngine,message:str) -> None:
|
|||||||
buffer_response += ch
|
buffer_response += ch
|
||||||
if len(buffer_response) > 20:
|
if len(buffer_response) > 20:
|
||||||
if ch in end_symbol:
|
if ch in end_symbol:
|
||||||
await play_vocal(buffer_response.strip())
|
if TTS_ENABLE:
|
||||||
|
await play_vocal(buffer_response.strip())
|
||||||
buffer_response = ""
|
buffer_response = ""
|
||||||
buffer_response = buffer_response.strip()
|
buffer_response = buffer_response.strip()
|
||||||
if len(buffer_response) > 0:
|
if len(buffer_response) > 0:
|
||||||
await play_vocal(buffer_response)
|
if TTS_ENABLE:
|
||||||
|
await play_vocal(buffer_response)
|
||||||
|
|
||||||
|
|
||||||
def add_speaker() -> None:
|
def add_speaker() -> None:
|
||||||
@@ -317,8 +323,11 @@ def add_speaker() -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def event_loop(engine:SimpleChatEngine) -> None:
|
async def event_loop(engine:SimpleChatEngine) -> None:
|
||||||
add_speaker()
|
if TTS_ENABLE:
|
||||||
audio_player_task = asyncio.create_task(audio_player_worker())
|
add_speaker()
|
||||||
|
audio_player_task = asyncio.create_task(audio_player_worker())
|
||||||
|
else:
|
||||||
|
audio_player_task = None
|
||||||
message = input("请开始对话: ")
|
message = input("请开始对话: ")
|
||||||
wait_second = AUTO_SPEAK_WAIT_SECOND
|
wait_second = AUTO_SPEAK_WAIT_SECOND
|
||||||
try:
|
try:
|
||||||
@@ -332,10 +341,11 @@ async def event_loop(engine:SimpleChatEngine) -> None:
|
|||||||
else:
|
else:
|
||||||
wait_second = AUTO_SPEAK_WAIT_SECOND
|
wait_second = AUTO_SPEAK_WAIT_SECOND
|
||||||
finally:
|
finally:
|
||||||
await audio_play_queue.join()
|
if TTS_ENABLE and audio_player_task is not None:
|
||||||
await audio_play_queue.put(None)
|
await audio_play_queue.join()
|
||||||
await audio_player_task
|
await audio_play_queue.put(None)
|
||||||
cleanup_audio()
|
await audio_player_task
|
||||||
|
cleanup_audio()
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|||||||
1
pip_install.bat
Normal file
1
pip_install.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
|
||||||
@@ -95,7 +95,6 @@ pydantic==2.7.0
|
|||||||
pydantic_core==2.18.1
|
pydantic_core==2.18.1
|
||||||
pydub==0.25.1
|
pydub==0.25.1
|
||||||
Pygments==2.19.2
|
Pygments==2.19.2
|
||||||
pynini @ file:///D:/bld/pynini_1696660974449/work
|
|
||||||
pyparsing==3.2.5
|
pyparsing==3.2.5
|
||||||
pyreadline3==3.5.4
|
pyreadline3==3.5.4
|
||||||
PySocks==1.7.1
|
PySocks==1.7.1
|
||||||
|
|||||||
Reference in New Issue
Block a user