1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-30 19:07:39 +03:00

feat(python tcp server): prepare ASR entry point

This commit is contained in:
louistiti 2024-05-19 11:46:47 +08:00
parent b25b82b9dc
commit ed42f9b752
No known key found for this signature in database
GPG Key ID: 92CD6A2E497E1669
3 changed files with 12 additions and 1 deletions

View File

@ -21,3 +21,6 @@ TTS_MODEL_FOLDER_PATH = os.path.join(TTS_LIB_PATH, 'models')
TTS_MODEL_CONFIG_PATH = os.path.join(TTS_MODEL_FOLDER_PATH, 'config.json')
TTS_MODEL_PATH = os.path.join(TTS_MODEL_FOLDER_PATH, TTS_MODEL_FILE_NAME)
IS_TTS_ENABLED = os.environ.get('LEON_TTS', 'true') == 'true'
# ASR
IS_ASR_ENABLED = os.environ.get('LEON_STT', 'true') == 'true'

View File

@ -7,7 +7,7 @@ import re
import lib.nlp as nlp
from .tts.api import TTS
from .constants import TTS_MODEL_CONFIG_PATH, TTS_MODEL_PATH, IS_TTS_ENABLED, TMP_PATH
from .constants import TTS_MODEL_CONFIG_PATH, TTS_MODEL_PATH, IS_TTS_ENABLED, TMP_PATH, IS_ASR_ENABLED
class TCPServer:
@ -42,6 +42,13 @@ class TCPServer:
ckpt_path=TTS_MODEL_PATH
)
def init_asr(self):
if not IS_ASR_ENABLED:
self.log('ASR is disabled')
return
# TODO
def init(self):
try:
# Make sure to establish TCP connection by reusing the address so it does not conflict with port already in use

View File

@ -15,4 +15,5 @@ tcp_server_port = os.environ.get('LEON_PY_TCP_SERVER_PORT', 1342)
tcp_server = TCPServer(tcp_server_host, tcp_server_port)
tcp_server.init_tts()
tcp_server.init_asr()
tcp_server.init()