修复一些问题, 添加缺失的TTS_ENABLE
This commit is contained in:
10
cli.py
10
cli.py
@@ -25,6 +25,7 @@ TEMPERATURE = config.FindItem("temperature", 1.3)
|
||||
MAX_CONTENT_LENGTH = config.FindItem("max_content_length", None)
|
||||
SYSTEM_PROMPT_PATH = config.FindItem("system_prompt_path", None)
|
||||
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_PROMPT_TEXT = config.FindItem("tts_prompt_text", 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"SYSTEM_PROMPT_PATH: {SYSTEM_PROMPT_PATH}")
|
||||
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
|
||||
|
||||
ollama_llm_config = {
|
||||
@@ -202,6 +204,8 @@ async def audio_player_worker():
|
||||
|
||||
# CHANGE TOCHECK
|
||||
async def play_vocal(text:str) -> None:
|
||||
if not TTS_ENABLE:
|
||||
return
|
||||
if len(text) == 0 or not text:
|
||||
return
|
||||
tts_server_url = f"{TTS_SERVER_URL}/api/synthesis/sft"
|
||||
@@ -287,10 +291,12 @@ async def achat(engine:SimpleChatEngine,message:str) -> None:
|
||||
buffer_response += ch
|
||||
if len(buffer_response) > 20:
|
||||
if ch in end_symbol:
|
||||
if TTS_ENABLE:
|
||||
await play_vocal(buffer_response.strip())
|
||||
buffer_response = ""
|
||||
buffer_response = buffer_response.strip()
|
||||
if len(buffer_response) > 0:
|
||||
if TTS_ENABLE:
|
||||
await play_vocal(buffer_response)
|
||||
|
||||
|
||||
@@ -317,8 +323,11 @@ def add_speaker() -> None:
|
||||
|
||||
|
||||
async def event_loop(engine:SimpleChatEngine) -> None:
|
||||
if TTS_ENABLE:
|
||||
add_speaker()
|
||||
audio_player_task = asyncio.create_task(audio_player_worker())
|
||||
else:
|
||||
audio_player_task = None
|
||||
message = input("请开始对话: ")
|
||||
wait_second = AUTO_SPEAK_WAIT_SECOND
|
||||
try:
|
||||
@@ -332,6 +341,7 @@ async def event_loop(engine:SimpleChatEngine) -> None:
|
||||
else:
|
||||
wait_second = AUTO_SPEAK_WAIT_SECOND
|
||||
finally:
|
||||
if TTS_ENABLE and audio_player_task is not None:
|
||||
await audio_play_queue.join()
|
||||
await audio_play_queue.put(None)
|
||||
await audio_player_task
|
||||
|
||||
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
|
||||
pydub==0.25.1
|
||||
Pygments==2.19.2
|
||||
pynini @ file:///D:/bld/pynini_1696660974449/work
|
||||
pyparsing==3.2.5
|
||||
pyreadline3==3.5.4
|
||||
PySocks==1.7.1
|
||||
|
||||
Reference in New Issue
Block a user