sending data to LLM; status
This commit is contained in:
parent
947956a37b
commit
169488818b
@ -3,13 +3,15 @@ import React, { Component } from 'react';
|
|||||||
import { View, Text, Button } from 'react-native';
|
import { View, Text, Button } from 'react-native';
|
||||||
import Voice from '@react-native-voice/voice';
|
import Voice from '@react-native-voice/voice';
|
||||||
|
|
||||||
import Config from 'react-native-config';
|
// import Config from 'react-native-config';
|
||||||
process.env.TTS_BACKEND_URL = Config.TTS_BACKEND_URL;
|
// 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 {
|
class VoiceHandler extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
|
status: '',
|
||||||
recognized: '',
|
recognized: '',
|
||||||
started: '',
|
started: '',
|
||||||
results: [],
|
results: [],
|
||||||
@ -66,7 +68,8 @@ class VoiceHandler extends Component {
|
|||||||
await Voice.stop();
|
await Voice.stop();
|
||||||
this.setState({
|
this.setState({
|
||||||
isRecording: false,
|
isRecording: false,
|
||||||
isProcessing:true
|
isProcessing:true,
|
||||||
|
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(this.state.results.join(' '));
|
this._sendTranscribedTextToLLM(this.state.results.join(' '));
|
||||||
@ -83,6 +86,9 @@ class VoiceHandler extends Component {
|
|||||||
messages: [{ role: "user", content: "I have a request: " + transcribedText }],
|
messages: [{ role: "user", content: "I have a request: " + transcribedText }],
|
||||||
stream: false,
|
stream: false,
|
||||||
};
|
};
|
||||||
|
this.setState({
|
||||||
|
status: ["sending to LLM:" + transcribedText]
|
||||||
|
})
|
||||||
try {
|
try {
|
||||||
|
|
||||||
console.log('sending text to LLM at ', LLM_ENDPOINT, ": '", transcribedText, "'");
|
console.log('sending text to LLM at ', LLM_ENDPOINT, ": '", transcribedText, "'");
|
||||||
@ -104,6 +110,7 @@ class VoiceHandler extends Component {
|
|||||||
console.log('LLM Response:', responseJson.message);
|
console.log('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",
|
||||||
results: [...prevState.results, responseJson.message.content], // Append the response to the existing results
|
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"}
|
title={this.state.isRecording ? "Stop Recognizing" : "Start Recognizing"}
|
||||||
color={this.state.isRecording ? "red" : this.state.isProcessing ? "orange" : "blue"} // Change color based on state
|
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>Recognized: {this.state.recognized}</Text>
|
||||||
<Text>Started: {this.state.started}</Text>
|
<Text>Started: {this.state.started}</Text>
|
||||||
<Text>Results: {this.state.results.join(' ')}</Text>
|
<Text>Results: {this.state.results.join(' ')}</Text>
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-native-voice/voice": "^3.2.4",
|
"@react-native-voice/voice": "^3.2.4",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-native": "0.73.4",
|
"react-native": "0.73.4"
|
||||||
"react-native-config": "^1.5.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.20.0",
|
"@babel/core": "^7.20.0",
|
||||||
|
@ -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 JAVA_HOME=/home/androidusr/download/jdk-17.0.8
|
||||||
export PATH=$JAVA_HOME/bin:$PATH
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
cd /opt/android/tools/bin
|
#cd /opt/android/tools/bin
|
||||||
yes | ./sdkmanager --licenses
|
#yes | ./sdkmanager --licenses
|
||||||
|
|
||||||
cd /home/androidusr/tmp
|
cd /home/androidusr/tmp
|
||||||
npx react-native run-android
|
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
|
The SDK directory is not writable (/opt/android) >> sudo chown -R androidusr:androidusr /opt/android
|
||||||
|
|
||||||
# release build
|
# release build
|
||||||
cd android
|
cd ~/tmp/android
|
||||||
./gradlew assembleRelease
|
./gradlew assembleRelease
|
||||||
|
Loading…
x
Reference in New Issue
Block a user