forked from open-edge-platform/edge-ai-suites
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathavatar3d_chat_online_voice.py
More file actions
67 lines (51 loc) · 1.78 KB
/
avatar3d_chat_online_voice.py
File metadata and controls
67 lines (51 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import argparse
def parse_args():
parser = argparse.ArgumentParser(
description="3D Avatar Client: Voice Chat",
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
return parser.parse_args()
def main(args):
from queue import Empty
from multiprocessing import Queue
from da import config
from da.avatar3d.render_integrator import RenderIntegrator
from da.listen.listener import Listener
from da.llm.ecrag_client import ECRAGRemoteClient
from da.llm.qwen_client import QwenLocalClient
from da.speak.tts_worker import TTSWorker
from da.util.log import logger
# load EC-RAG client
# llm_client = QwenLocalClient()
llm_client = ECRAGRemoteClient()
# load ASR
question_text_queue = Queue(1)
audio_queue = Queue(1)
hello_wav = config.tts.male_hello_wav if config.tts.male_hello_wav else config.tts.female_hello_wav
listener = Listener(question_text_queue, audio_queue, hello_wav)
# load tts model
answer_text_queue = Queue(1)
tts_worker = TTSWorker(config.tts.male_voice, answer_text_queue, audio_queue)
# Load avatar render.
avatar = RenderIntegrator(audio_queue)
avatar.start()
tts_worker.start()
listener.start()
logger.info("Listening...")
try:
while True:
try:
question = question_text_queue.get(timeout=1)
except Empty:
continue
if len(question.strip()) == 0:
continue
for answer in llm_client.generate_text_complete_sentences(question):
answer_text_queue.put(answer)
except KeyboardInterrupt:
logger.info("Exit...")
listener.stop()
tts_worker.stop()
avatar.stop()
if __name__ == '__main__':
main(parse_args())