From adfaff42772e052974c8d6ad0b855981c922f3ea Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Fri, 16 Feb 2024 20:56:10 +0200 Subject: [PATCH] http Logs --- .env | 2 +- .vscode/launch.json | 13 ++++++++++-- agent-mobile/artimobile/VoiceHandler.js | 28 ++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/.env b/.env index f0ffaa4..aa301cf 100644 --- a/.env +++ b/.env @@ -7,4 +7,4 @@ TTS_BACKEND_URL3=http://192.168.0.10:9008/asr #gpu TTS_BACKEND_URL4=http://192.168.0.10:9009/asr #cpu 9008-gpu WS_URL=ws://localhost:8081 SERVER_PORT_WS=8081 -SERVER_PORT_HTTP=8080 \ No newline at end of file +SERVER_PORT_HTTP=3005 \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index cc04cbc..d1eed27 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -25,7 +25,7 @@ }, { "name": "Docker Python Launch with venv", - "type": "python", + "type": "debugpy", "request": "launch", "program": "${workspaceFolder}/agent-py-bot/agent.py", "console": "integratedTerminal", @@ -33,7 +33,16 @@ "env": { "PYTHONUNBUFFERED": "1" } + }, + { + "name": "node: Launch server.js", + "type": "node", + "request": "launch", + "program": "conda activate node && node web/server.js", + "skipFiles": [ + "/**" + ] + } - ] } \ No newline at end of file diff --git a/agent-mobile/artimobile/VoiceHandler.js b/agent-mobile/artimobile/VoiceHandler.js index fb278a1..d70522a 100644 --- a/agent-mobile/artimobile/VoiceHandler.js +++ b/agent-mobile/artimobile/VoiceHandler.js @@ -11,7 +11,7 @@ process.env.TTS_BACKEND_URL = "https://tts.d-popov.com/asr" const LLM_ENDPOINT = "https://ws.ai.d-popov.com/api/chat"; // const LLM_ENDPOINT = "http://192.168.0.11:11434/api/chat"; -const LOG_ENDPOINT = "ws://192.168.0.11:9999"; +const LOG_ENDPOINT = "ws://192.168.0.11:3005/log"; class VoiceHandler extends Component { constructor(props) { @@ -30,6 +30,8 @@ class VoiceHandler extends Component { Voice.onSpeechResults = this.onSpeechResults.bind(this); } + + componentWillUnmount() { Voice.destroy().then(Voice.removeAllListeners); } @@ -53,7 +55,26 @@ class VoiceHandler extends Component { recognized: [...recognized, e.value], status: this.state.status+ "\nonSpeechResults():" + e.value }); - console.log("onSpeechResults():" + e.value); + + this.logRemote("onSpeechResults():" + e.value); + } + + + async logRemote(message){ + try{ + fetch(LOG_ENDPOINT, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({"message":message}), + }); + + } + catch(e){ + console.log("error logging:" + e); + } + console.log( message ); } async _startRecognizing(e) { @@ -103,7 +124,7 @@ class VoiceHandler extends Component { }) try { - console.log('sending text to LLM at ', LLM_ENDPOINT, ": '", transcribedText, "'"); + this.logRemote('sending text to LLM at ', LLM_ENDPOINT, ": '", transcribedText, "'"); const response = await fetch(LLM_ENDPOINT, { method: 'POST', headers: { @@ -142,6 +163,7 @@ class VoiceHandler extends Component { } } + _sendAudioToBackend(results) { // Placeholder: Convert `results` or actual audio data to a format acceptable by your backend const formData = new FormData();