sending data to LLM; status

This commit is contained in:
Dobromir Popov 2024-02-15 02:33:16 +02:00
parent 947956a37b
commit 169488818b
3 changed files with 15 additions and 8 deletions

View File

@ -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>

View File

@ -12,8 +12,7 @@
"dependencies": {
"@react-native-voice/voice": "^3.2.4",
"react": "18.2.0",
"react-native": "0.73.4",
"react-native-config": "^1.5.1"
"react-native": "0.73.4"
},
"devDependencies": {
"@babel/core": "^7.20.0",

View File

@ -53,8 +53,8 @@ tar -xzf jdk-17.0.8_linux-x64_bin.tar.gz -C /home/androidusr/download
export JAVA_HOME=/home/androidusr/download/jdk-17.0.8
export PATH=$JAVA_HOME/bin:$PATH
source ~/.bashrc
cd /opt/android/tools/bin
yes | ./sdkmanager --licenses
#cd /opt/android/tools/bin
#yes | ./sdkmanager --licenses
cd /home/androidusr/tmp
npx react-native run-android
@ -71,5 +71,5 @@ react-native link @react-native-voice/voice
The SDK directory is not writable (/opt/android) >> sudo chown -R androidusr:androidusr /opt/android
# release build
cd android
cd ~/tmp/android
./gradlew assembleRelease