sending data to LLM; status
This commit is contained in:
@ -3,13 +3,15 @@ import React, { Component } from 'react';
|
||||
import { View, Text, Button } from 'react-native';
|
||||
import Voice from '@react-native-voice/voice';
|
||||
|
||||
import Config from 'react-native-config';
|
||||
process.env.TTS_BACKEND_URL = Config.TTS_BACKEND_URL;
|
||||
// import Config from 'react-native-config';
|
||||
// process.env.TTS_BACKEND_URL = Config.TTS_BACKEND_URL;
|
||||
process.env.TTS_BACKEND_URL = "http://192.168.0.10:9008/asr"
|
||||
|
||||
class VoiceHandler extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
status: '',
|
||||
recognized: '',
|
||||
started: '',
|
||||
results: [],
|
||||
@ -66,7 +68,8 @@ class VoiceHandler extends Component {
|
||||
await Voice.stop();
|
||||
this.setState({
|
||||
isRecording: false,
|
||||
isProcessing:true
|
||||
isProcessing:true,
|
||||
recognized: this.state.results.join(' ')
|
||||
});
|
||||
// Assuming you have the audio data, send it to your backend
|
||||
this._sendTranscribedTextToLLM(this.state.results.join(' '));
|
||||
@ -83,6 +86,9 @@ class VoiceHandler extends Component {
|
||||
messages: [{ role: "user", content: "I have a request: " + transcribedText }],
|
||||
stream: false,
|
||||
};
|
||||
this.setState({
|
||||
status: ["sending to LLM:" + transcribedText]
|
||||
})
|
||||
try {
|
||||
|
||||
console.log('sending text to LLM at ', LLM_ENDPOINT, ": '", transcribedText, "'");
|
||||
@ -104,6 +110,7 @@ class VoiceHandler extends Component {
|
||||
console.log('LLM Response:', responseJson.message);
|
||||
// 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
|
||||
}));
|
||||
}
|
||||
@ -155,6 +162,7 @@ class VoiceHandler extends Component {
|
||||
title={this.state.isRecording ? "Stop Recognizing" : "Start Recognizing"}
|
||||
color={this.state.isRecording ? "red" : this.state.isProcessing ? "orange" : "blue"} // Change color based on state
|
||||
/>
|
||||
<Text>Status: {this.state.status}</Text>
|
||||
<Text>Recognized: {this.state.recognized}</Text>
|
||||
<Text>Started: {this.state.started}</Text>
|
||||
<Text>Results: {this.state.results.join(' ')}</Text>
|
||||
|
Reference in New Issue
Block a user