Merge branch 'niki-tradingview'

This commit is contained in:
Dobromir Popov 2024-02-16 21:02:10 +02:00
commit ac276ade0a
2 changed files with 26 additions and 4 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

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();