http Logs

This commit is contained in:
Dobromir Popov 2024-02-16 20:56:10 +02:00
parent e72b03f5dc
commit adfaff4277
3 changed files with 37 additions and 6 deletions

2
.env
View File

@ -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 TTS_BACKEND_URL4=http://192.168.0.10:9009/asr #cpu 9008-gpu
WS_URL=ws://localhost:8081 WS_URL=ws://localhost:8081
SERVER_PORT_WS=8081 SERVER_PORT_WS=8081
SERVER_PORT_HTTP=8080 SERVER_PORT_HTTP=3005

13
.vscode/launch.json vendored
View File

@ -25,7 +25,7 @@
}, },
{ {
"name": "Docker Python Launch with venv", "name": "Docker Python Launch with venv",
"type": "python", "type": "debugpy",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/agent-py-bot/agent.py", "program": "${workspaceFolder}/agent-py-bot/agent.py",
"console": "integratedTerminal", "console": "integratedTerminal",
@ -33,7 +33,16 @@
"env": { "env": {
"PYTHONUNBUFFERED": "1" "PYTHONUNBUFFERED": "1"
} }
},
{
"name": "node: Launch server.js",
"type": "node",
"request": "launch",
"program": "conda activate node && node web/server.js",
"skipFiles": [
"<node_internals>/**"
]
} }
] ]
} }

View File

@ -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 = "https://ws.ai.d-popov.com/api/chat";
// const LLM_ENDPOINT = "http://192.168.0.11:11434/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 { class VoiceHandler extends Component {
constructor(props) { constructor(props) {
@ -30,6 +30,8 @@ class VoiceHandler extends Component {
Voice.onSpeechResults = this.onSpeechResults.bind(this); Voice.onSpeechResults = this.onSpeechResults.bind(this);
} }
componentWillUnmount() { componentWillUnmount() {
Voice.destroy().then(Voice.removeAllListeners); Voice.destroy().then(Voice.removeAllListeners);
} }
@ -53,7 +55,26 @@ class VoiceHandler extends Component {
recognized: [...recognized, e.value], recognized: [...recognized, e.value],
status: this.state.status+ "\nonSpeechResults():" + 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) { async _startRecognizing(e) {
@ -103,7 +124,7 @@ class VoiceHandler extends Component {
}) })
try { 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, { const response = await fetch(LLM_ENDPOINT, {
method: 'POST', method: 'POST',
headers: { headers: {
@ -142,6 +163,7 @@ class VoiceHandler extends Component {
} }
} }
_sendAudioToBackend(results) { _sendAudioToBackend(results) {
// Placeholder: Convert `results` or actual audio data to a format acceptable by your backend // Placeholder: Convert `results` or actual audio data to a format acceptable by your backend
const formData = new FormData(); const formData = new FormData();