http log over https

This commit is contained in:
Dobromir Popov
2024-02-16 21:46:17 +02:00
parent c8fd2d2594
commit c049dc3844
2 changed files with 11 additions and 9 deletions

View File

@ -11,7 +11,7 @@ process.env.TTS_BACKEND_URL = "https://tts.d-popov.com/asr"
process.env.LLM_ENDPOINT = "https://ws.ai.d-popov.com/api/chat"; process.env.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";
process.env.LOG_ENDPOINT = "http://192.168.0.11:3005/log"; process.env.LOG_ENDPOINT = "https://dev.d-popov.com/log";
class VoiceHandler extends Component { class VoiceHandler extends Component {
constructor(props) { constructor(props) {
@ -21,6 +21,7 @@ class VoiceHandler extends Component {
recognized: '', recognized: '',
started: '', started: '',
results: [], results: [],
response:[],
isRecording: false, isRecording: false,
isProcessing: false, isProcessing: false,
}; };
@ -47,12 +48,13 @@ class VoiceHandler extends Component {
this.setState({ this.setState({
status: "Recognized" status: "Recognized"
}); });
console.log("onSpeechRecognized()"); this.logRemote("onSpeechRecognized()");
} }
onSpeechResults(e) { onSpeechResults(e) {
this.setState({ this.setState({
recognized: [...recognized, e.value], results: e.value,
recognized: recognized + " " + e.value,
status: this.state.status+ "\nonSpeechResults():" + e.value status: this.state.status+ "\nonSpeechResults():" + e.value
}); });
@ -100,11 +102,11 @@ class VoiceHandler extends Component {
this.setState({ this.setState({
isRecording: false, isRecording: false,
isProcessing:true, isProcessing:true,
status: this.state.status+ "\nstopRecognizing()" + this.state.recognized recognized: this.state.results.join(' ')
}); });
// Assuming you have the audio data, send it to your backend // Assuming you have the audio data, send it to your backend
this._sendTranscribedTextToLLM("who is the president of thr USA"); // this._sendTranscribedTextToLLM("who is the president of thr USA");
//this._sendTranscribedTextToLLM(this.state.recognized); this._sendTranscribedTextToLLM(this.state.results.join(' '));
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
@ -139,7 +141,7 @@ class VoiceHandler extends Component {
// Handle error appropriately in your app // Handle error appropriately in your app
} else { } else {
// Handle successful response // Handle successful response
console.log('LLM Response:', responseJson.message); this.logRemote('LLM Response:', responseJson.message);
// Update your app state or UI based on LLM response // Update your app state or UI based on LLM response
this.setState(prevState => ({ this.setState(prevState => ({
status: "LLM responded", status: "LLM responded",
@ -177,7 +179,7 @@ class VoiceHandler extends Component {
}) })
.then(response => response.text()) .then(response => response.text())
.then(body => { .then(body => {
console.log('Audio sent to backend, response:', body); this.logRemote('Audio sent to backend, response:', body);
this.setState(prevState => ({ this.setState(prevState => ({
results: [...prevState.results, body], // Append the response to the existing results results: [...prevState.results, body], // Append the response to the existing results
})); }));

View File

@ -120,7 +120,7 @@ app.get('/', (req, res) => {
//accept LOG messages on /log //accept LOG messages on /log
app.post('/log', (req, res) => { app.post('/log', (req, res) => {
console.log(req.body.message); console.log("log>" + req.body.message);
res.send('OK', 200, { 'Content-Type': 'text/plain' }); res.send('OK', 200, { 'Content-Type': 'text/plain' });
}); });