|
|
@ -10,10 +10,11 @@ from typing import List, Dict, Any
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import importlib.util
|
|
|
|
import importlib.util
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
os.environ["STT_RUNNER"] = "server"
|
|
|
|
os.environ["STT_RUNNER"] = "server"
|
|
|
|
os.environ["TTS_RUNNER"] = "server"
|
|
|
|
os.environ["TTS_RUNNER"] = "server"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
|
|
app.add_middleware(
|
|
|
|
app.add_middleware(
|
|
|
@ -40,6 +41,9 @@ async def websocket_endpoint(
|
|
|
|
):
|
|
|
|
):
|
|
|
|
await websocket.accept()
|
|
|
|
await websocket.accept()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global global_interpreter
|
|
|
|
|
|
|
|
interpreter = global_interpreter
|
|
|
|
|
|
|
|
|
|
|
|
# Send the tts_service value to the client
|
|
|
|
# Send the tts_service value to the client
|
|
|
|
await websocket.send_text(
|
|
|
|
await websocket.send_text(
|
|
|
|
json.dumps({"type": "config", "tts_service": interpreter.interpreter.tts})
|
|
|
|
json.dumps({"type": "config", "tts_service": interpreter.interpreter.tts})
|
|
|
@ -104,6 +108,9 @@ async def main(server_host, server_port, profile, debug):
|
|
|
|
# Make it async
|
|
|
|
# Make it async
|
|
|
|
interpreter = AsyncInterpreter(interpreter, debug)
|
|
|
|
interpreter = AsyncInterpreter(interpreter, debug)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global global_interpreter
|
|
|
|
|
|
|
|
global_interpreter = interpreter
|
|
|
|
|
|
|
|
|
|
|
|
print(f"Starting server on {server_host}:{server_port}")
|
|
|
|
print(f"Starting server on {server_host}:{server_port}")
|
|
|
|
config = Config(app, host=server_host, port=server_port, lifespan="on")
|
|
|
|
config = Config(app, host=server_host, port=server_port, lifespan="on")
|
|
|
|
server = Server(config)
|
|
|
|
server = Server(config)
|
|
|
|