logs
This commit is contained in:
parent
c049dc3844
commit
e5358562f4
@ -54,30 +54,14 @@ class VoiceHandler extends Component {
|
||||
onSpeechResults(e) {
|
||||
this.setState({
|
||||
results: e.value,
|
||||
recognized: recognized + " " + e.value,
|
||||
status: this.state.status+ "\nonSpeechResults():" + e.value
|
||||
// recognized: recognized + " " + e.value,
|
||||
// status: this.state.status+ "\nonSpeechResults():" + e.value
|
||||
});
|
||||
|
||||
this.logRemote("onSpeechResults():" + e.value);
|
||||
this.logRemote("onSpeechResults():" + e.value.join(' '));
|
||||
}
|
||||
|
||||
|
||||
async logRemote(message){
|
||||
try{
|
||||
fetch(process.env.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) {
|
||||
this.setState({
|
||||
recognized: '',
|
||||
@ -99,18 +83,20 @@ class VoiceHandler extends Component {
|
||||
async _stopRecognizing() {
|
||||
try {
|
||||
await Voice.stop();
|
||||
const input = this.state.results.join(' ')
|
||||
this.setState({
|
||||
isRecording: false,
|
||||
isProcessing:true,
|
||||
recognized: this.state.results.join(' ')
|
||||
recognized: input
|
||||
});
|
||||
// Assuming you have the audio data, send it to your backend
|
||||
// this._sendTranscribedTextToLLM("who is the president of thr USA");
|
||||
this._sendTranscribedTextToLLM(this.state.results.join(' '));
|
||||
this._sendTranscribedTextToLLM(input);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async _sendTranscribedTextToLLM(transcribedText) {
|
||||
|
||||
const model = "openhermes:latest";
|
||||
@ -145,7 +131,7 @@ class VoiceHandler extends Component {
|
||||
// Update your app state or UI based on LLM response
|
||||
this.setState(prevState => ({
|
||||
status: "LLM responded",
|
||||
results: [...prevState.results, responseJson.message.content], // Append the response to the existing results
|
||||
response: [...prevState.response, responseJson.message.content], // Append the response to the existing results
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
@ -188,6 +174,22 @@ class VoiceHandler extends Component {
|
||||
console.error('Failed to send audio:', error);
|
||||
});
|
||||
}
|
||||
|
||||
async logRemote(message){
|
||||
try{
|
||||
fetch(process.env.LOG_ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({"message":message}),
|
||||
});
|
||||
}
|
||||
catch(e){
|
||||
console.log("error logging:" + e);
|
||||
}
|
||||
console.log( message );
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
@ -206,6 +208,8 @@ class VoiceHandler extends Component {
|
||||
<Text key={index}>{r}</Text>
|
||||
))}
|
||||
</View>
|
||||
|
||||
<Text>AI: </Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ app.get('/', (req, res) => {
|
||||
|
||||
//accept LOG messages on /log
|
||||
app.post('/log', (req, res) => {
|
||||
console.log("log>" + req.body.message);
|
||||
console.log("log["+new Date().toISOString() + '] ' + req.body.message);
|
||||
res.send('OK', 200, { 'Content-Type': 'text/plain' });
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user