Commit a8337d89 authored by Lihinikaduwa D.N.R.  's avatar Lihinikaduwa D.N.R.

Some Changes

parent 14cb368e
......@@ -243,4 +243,4 @@ def reading_result(userId):
if __name__ == "__main__":
app.run(host='192.168.8.100')
app.run(host='192.168.1.101')
......@@ -12,7 +12,7 @@ def create_con():
database="helply",
host="127.0.0.1",
user="root",
password="rp19970520"
password="12345678"
)
return db
......
......@@ -4,7 +4,7 @@ from API.util.util import getUUID
def get_reading_result(userId):
qry = 'SELECT userId,word,triedCount,level FROM reading WHERE userId = "{}"'.format(userId)
qry = 'SELECT word,triedCount,level FROM reading WHERE userId = "{}"'.format(userId)
return get_data(qry)
......
export const ImagePaths = {
roundOne: require('../image/round1.jpeg'),
roundTwo: require('../image/round2.png'),
summery: require('../image/ReadHeaderImg4.webp'),
summery2: require('../image/ReadHeaderImg4.webp'),
summery: require('../image/ReadHeaderImg45.jpg'),
robot1: require('../image/robot1.png'),
robot2: require('../image/activity-2-rob.png'),
backgroundBasic: require('../image/activity-2-backg.jpeg'),
......@@ -12,6 +13,10 @@ export const ImagePaths = {
bird: require('../image/bird.png'),
dog: require('../image/dog.png'),
fish: require('../image/fish.png'),
retry: require('../image/retry.png'),
wrong: require('../image/wrong.png'),
correct: require('../image/correct.png'),
chart: require('../image/chart.png'),
};
export const DummyReadResult = {
......
......@@ -42,7 +42,7 @@ export default function ReadModal(props) {
style={[styles.buttonClose2]}
onPress={() => navigation.navigate(path)}>
<Image
source={ImagePaths.robot1}
source={ImagePaths.correct}
resizeMode="contain"
style={{width: 100, height: 70, marginBottom: -10}}
/>
......@@ -174,7 +174,7 @@ const styles = StyleSheet.create({
marginBottom: 20,
},
alert2: {
backgroundColor: 'white',
backgroundColor: 'rgba(0, 181, 0, 0.45)',
borderRadius: 50,
width: 100,
height: 100,
......
import React, {useEffect, useState} from 'react';
import {
Text,
TouchableOpacity,
StyleSheet,
View,
ImageButton,
SafeAreaView,
ImageBackground,
Modal,
Image,
TouchableHighlight,
} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import {ImagePaths} from '../../assets/read/data/ReadData';
export default function ReadModalFailed(props) {
const {caption, validity, visibility, path} = props;
const navigation = useNavigation();
const [modalVisible, setModalVisible] = useState(visibility);
const navigate = () => {};
return (
<Modal
animationType="fade"
transparent={true}
hidden={true}
visible={modalVisible}
// onRequestClose={() => {
// setModalVisible3(!modalVisible3);
// }}
>
<View style={styles.centeredView3}>
<View style={styles.modalView3}>
<Image style={styles.alert3} source={ImagePaths.robot1}></Image>
<Text style={styles.headStyle3}>Your answer is</Text>
<Text style={styles.head2Style3}>Incorect.</Text>
<TouchableOpacity style={[]} onPress={() => setModalVisible(false)}>
<Image
source={ImagePaths.retry}
resizeMode="contain"
style={{width: 100, height: 70, marginBottom: -1}}
/>
</TouchableOpacity>
</View>
</View>
</Modal>
);
}
const styles = StyleSheet.create({
body: {
flex: 1,
},
image: {
width: '100%',
height: '100%',
},
blackboard: {
marginTop: -420,
marginLeft: 240,
width: '70%',
height: 500,
},
robo: {
marginTop: -70,
marginLeft: -5,
width: 150,
height: 200,
},
textBody: {
marginTop: 150,
marginLeft: 95,
backgroundColor: '#1DCE92',
width: 200,
borderRadius: 50,
padding: 5,
},
text: {
fontSize: 25,
justifyContent: 'center',
alignItems: 'center',
color: 'white',
textAlign: 'center',
fontWeight: 'bold',
},
button: {
padding: 10,
marginRight: 50,
color: '#000000',
marginLeft: 50,
},
centeredView: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
marginTop: -90,
marginLeft: -100,
},
modalView: {
marginRight: 20,
backgroundColor: '#00000000',
borderRadius: 20,
padding: 35,
alignItems: 'center',
},
button: {
borderRadius: 20,
padding: 10,
elevation: 2,
},
centeredView2: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
marginTop: 22,
},
modalView2: {
marginTop: -10,
margin: 20,
backgroundColor: '#FFFFFFEF',
borderRadius: 20,
padding: 35,
borderWidth: 5,
borderColor: '#red',
alignItems: 'center',
shadowColor: 'red',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
},
button2: {
borderRadius: 20,
padding: 10,
elevation: 2,
},
buttonOpen2: {
backgroundColor: '#F194FF',
},
buttonClose2: {
// backgroundColor: "#1DCE92",
},
textStyle2: {
color: 'white',
fontWeight: 'bold',
textAlign: 'center',
},
modalText2: {
marginBottom: 15,
textAlign: 'center',
},
headStyle2: {
color: 'black',
fontWeight: 'bold',
textAlign: 'center',
fontSize: 30,
marginBottom: 5,
},
head2Style2: {
color: 'black',
fontWeight: 'bold',
textAlign: 'center',
fontSize: 30,
marginBottom: 20,
},
alert2: {
backgroundColor: 'white',
borderRadius: 50,
width: 100,
height: 100,
marginBottom: 20,
marginTop: -80,
},
centeredView3: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
marginTop: -20,
},
modalView3: {
margin: 20,
backgroundColor: '#FFFFFF',
borderRadius: 20,
padding: 20,
borderWidth: 5,
borderColor: '#1DCE92',
alignItems: 'center',
shadowColor: 'red',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
},
button3: {
borderRadius: 20,
padding: 10,
elevation: 2,
},
buttonOpen3: {
backgroundColor: '#F194FF',
},
buttonClose3: {
backgroundColor: '#1DCE92',
},
textStyle3: {
color: 'white',
fontWeight: 'bold',
textAlign: 'center',
},
headStyle3: {
color: 'black',
fontWeight: 'bold',
textAlign: 'center',
fontSize: 30,
marginBottom: 5,
},
head2Style3: {
color: 'black',
fontWeight: 'bold',
textAlign: 'center',
fontSize: 30,
marginBottom: 20,
},
modalText3: {
marginBottom: 15,
textAlign: 'center',
},
alert3: {
backgroundColor: 'rgba(255, 0, 0, 0.74)',
borderRadius: 50,
width: 100,
height: 100,
marginBottom: 20,
marginTop: -65,
},
});
......@@ -35,7 +35,7 @@ export default function TableList() {
Client.get('result/' + userId)
.then(response => {
setTableData({
tableHead: ['Date', 'Word', 'Count', 'Level'],
tableHead: ['Word', 'Count', 'Level'],
data: response.data.data,
});
})
......@@ -54,14 +54,14 @@ export default function TableList() {
<Table borderStyle={{borderWidth: 3, borderColor: '#fff'}}>
<Row
data={tableData.tableHead}
flexArr={[1, 1.5, 1, 1]}
flexArr={[ 1, 1, 1.5]}
style={styles.head}
textStyle={styles.text}
/>
<TableWrapper style={styles.wrapper}>
<Rows
data={tableData.data}
flexArr={[1, 1.5, 1, 1]}
flexArr={[1, 1, 1.5]}
style={styles.row}
textStyle={styles.text}
/>
......
......@@ -2,6 +2,6 @@ import axios from 'axios';
// export default axios.create({ baseURL: 'http://192.168.8.102:5000/', timeout: 15000, });
export default axios.create({
baseURL: 'http://192.168.8.100:5000/',
baseURL: 'http://192.168.1.101:5000/',
timeout: 15000,
});
......@@ -19,6 +19,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import {Authorize} from '../../auth/AuthenticateUser';
import Client from '../../client/Client';
import ReadModal from '../../../component/reading/ReadModal';
import ReadModalFailed from '../../../component/reading/ReadModalFailed';
export default function ReadActivityBird() {
const navigation = useNavigation();
......@@ -63,7 +64,26 @@ export default function ReadActivityBird() {
};
const onSpeechResultsHandler = e => {
console.log('result handler =>> ', e);
const result = e.value;
if (result.includes('bird')) {
AsyncStorage.getItem('userId')
.then(userId => {
const data = {
word: 'Bird',
userId: userId,
level: 'Advance',
triedCount: count,
};
getToken(data);
})
.catch(error => {
console.log(error);
});
} else {
setCount(count + 1);
setModalVisible3(true);
startRecording();
}
};
const onSpeechError = e => {
......@@ -121,13 +141,7 @@ export default function ReadActivityBird() {
/>
)}
{modalVisible3 && (
<ReadModal
caption="Misronunciation"
validity="Please Try Again."
visible="true"
/>
)}
{modalVisible3 && <ReadModalFailed visible="true" />}
<View style={{flexDirection: 'column'}}>
<ImageBackground
style={styles.image}
......
......@@ -19,6 +19,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import {Authorize} from '../../auth/AuthenticateUser';
import Client from '../../client/Client';
import ReadModal from '../../../component/reading/ReadModal';
import ReadModalFailed from '../../../component/reading/ReadModalFailed';
export default function ReadActivityDog() {
const navigation = useNavigation();
......@@ -63,7 +64,26 @@ export default function ReadActivityDog() {
};
const onSpeechResultsHandler = e => {
console.log('result handler =>> ', e);
const result = e.value;
if (result.includes('dog')) {
AsyncStorage.getItem('userId')
.then(userId => {
const data = {
word: 'Dog',
userId: userId,
level: 'Advance',
triedCount: count,
};
getToken(data);
})
.catch(error => {
console.log(error);
});
} else {
setCount(count + 1);
setModalVisible3(true);
startRecording();
}
};
const onSpeechError = e => {
......@@ -121,13 +141,7 @@ export default function ReadActivityDog() {
/>
)}
{modalVisible3 && (
<ReadModal
caption="Misronunciation"
validity="Please Try Again."
visible="true"
/>
)}
{modalVisible3 && <ReadModalFailed visible="true" />}
<View style={{flexDirection: 'column'}}>
<ImageBackground
style={styles.image}
......
......@@ -19,6 +19,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import {Authorize} from '../../auth/AuthenticateUser';
import Client from '../../client/Client';
import ReadModal from '../../../component/reading/ReadModal';
import ReadModalFailed from '../../../component/reading/ReadModalFailed';
export default function ReadActivityFish() {
const navigation = useNavigation();
......@@ -76,7 +77,26 @@ export default function ReadActivityFish() {
};
const onSpeechStartHandler = e => {
console.log('start handler =>> ', e);
const result = e.value;
if (result.includes('fish')) {
AsyncStorage.getItem('userId')
.then(userId => {
const data = {
word: 'Fish',
userId: userId,
level: 'Advance',
triedCount: count,
};
getToken(data);
})
.catch(error => {
console.log(error);
});
} else {
setCount(count + 1);
setModalVisible3(true);
startRecording();
}
};
const onSpeechResultsHandler = e => {
......@@ -138,13 +158,7 @@ export default function ReadActivityFish() {
/>
)}
{modalVisible3 && (
<ReadModal
caption="Misronunciation"
validity="Please Try Again."
visible="true"
/>
)}
{modalVisible3 && <ReadModalFailed visible="true" />}
<View style={{flexDirection: 'column'}}>
<ImageBackground
style={styles.image}
......
......@@ -19,6 +19,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import {Authorize} from '../../auth/AuthenticateUser';
import Client from '../../client/Client';
import ReadModal from '../../../component/reading/ReadModal';
import ReadModalFailed from '../../../component/reading/ReadModalFailed';
export default function ReadActivityGo() {
const navigation = useNavigation();
......@@ -63,7 +64,26 @@ export default function ReadActivityGo() {
};
const onSpeechResultsHandler = e => {
console.log('result handler =>> ', e);
const result = e.value;
if (result.includes('go')) {
AsyncStorage.getItem('userId')
.then(userId => {
const data = {
word: 'Go',
userId: userId,
level: 'Basic',
triedCount: count,
};
getToken(data);
})
.catch(error => {
console.log(error);
});
} else {
setCount(count + 1);
setModalVisible3(true);
startRecording();
}
};
const onSpeechError = e => {
......@@ -121,13 +141,7 @@ export default function ReadActivityGo() {
/>
)}
{modalVisible3 && (
<ReadModal
caption="Misronunciation"
validity="Please Try Again."
visible="true"
/>
)}
{modalVisible3 && <ReadModalFailed visible="true" />}
<View style={{flexDirection: 'column'}}>
<ImageBackground
style={styles.image}
......
......@@ -19,6 +19,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import {Authorize} from '../../auth/AuthenticateUser';
import Client from '../../client/Client';
import ReadModal from '../../../component/reading/ReadModal';
import ReadModalFailed from '../../../component/reading/ReadModalFailed';
export default function ReadActivityHe() {
const navigation = useNavigation();
......@@ -50,7 +51,8 @@ export default function ReadActivityHe() {
},
})
.then(res => {
updateReadingSession(readingSession);
setModalVisible2(true);
// updateReadingSession(readingSession);
})
.catch(error => {
console.log(error);
......@@ -80,7 +82,26 @@ export default function ReadActivityHe() {
};
const onSpeechResultsHandler = e => {
console.log('result handler =>> ', e);
const result = e.value;
if (result.includes('He')) {
AsyncStorage.getItem('userId')
.then(userId => {
const data = {
word: 'He',
userId: userId,
level: 'Basic',
triedCount: count,
};
getToken(data);
})
.catch(error => {
console.log(error);
});
} else {
setCount(count + 1);
setModalVisible3(true);
startRecording();
}
};
const onSpeechError = e => {
......@@ -138,14 +159,7 @@ export default function ReadActivityHe() {
/>
)}
{modalVisible3 && (
<ReadModal
caption="Misronunciation"
validity="Please Try Again."
visible="true"
// path="ReadActivityGo"
/>
)}
{modalVisible3 && <ReadModalFailed visible="true" />}
<View style={{flexDirection: 'column'}}>
<ImageBackground
style={styles.image}
......
......@@ -21,6 +21,7 @@ import AudioRecord from 'react-native-audio-record';
import CountDown from 'react-native-countdown-component';
import Client from '../../client/Client';
import ReadModal from '../../../component/reading/ReadModal';
import ReadModalFailed from '../../../component/reading/ReadModalFailed';
export default function ReadActivityNo() {
const navigation = useNavigation();
......@@ -30,6 +31,19 @@ export default function ReadActivityNo() {
const [modalVisible2, setModalVisible2] = useState(false);
const [modalVisible3, setModalVisible3] = useState(false);
React.useEffect(() => {
// StatusBar.setHidden(true);
//
audioInit();
const unsubscribe = navigation.addListener('focus', () => {
Orientation.unlockAllOrientations();
Orientation.lockToPortrait();
});
return unsubscribe;
}, [navigation]);
useEffect(() => {
Voice.onSpeechStart = onSpeechStartHandler;
Voice.onSpeechResults = onSpeechResultsHandler;
......@@ -40,6 +54,70 @@ export default function ReadActivityNo() {
};
}, []);
function audioInit() {
// console.log('audioInit');
const colorAudio = {
sampleRate: 16000,
channels: 1,
bitsPerSample: 16,
wavFile: 'color.wav', // thise wave file name
};
AudioRecord.init(colorAudio);
}
async function audioStart() {
// console.log('audioStart');
// checkPermission();
AudioRecord.start();
setTimeout(() => {
audioStop();
}, 2000);
}
async function audioStop() {
// console.log('audioStop');
let audioFile = await AudioRecord.stop();
// console.log('userFile', audioFile);
sendAudio(audioFile);
}
function sendAudio(audioFile) {
var obj = {
uri: `file:${audioFile}`,
type: 'audio/wav',
name: secondColor[0] + '.wav',
};
var data = JSON.stringify(obj);
// console.log(data);
Client.post('predict', data, {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
.then(response => {
// setNames(response.data);
console.log('Success part : ', response.data);
})
.catch(function (error) {
if (error.response) {
console.log('Error data : ', error.response.data);
console.log('Error status : ', error.response.status);
console.log('Error headers : ', error.response.headers);
} else if (error.request) {
console.log('Error request : ', error.request);
} else {
console.log('Error message : ', error.message);
}
console.log('Error else part : ', error.config);
});
}
const sendRedingData = (data, readingSession) => {
Client.post('reading/' + readingSession, JSON.stringify(data), {
headers: {
......@@ -61,13 +139,33 @@ export default function ReadActivityNo() {
};
const onSpeechResultsHandler = e => {
console.log('result handler =>> ', e);
const result = e.value;
if (result.includes('no')) {
AsyncStorage.getItem('userId')
.then(userId => {
const data = {
word: 'No',
userId: userId,
level: 'Basic',
triedCount: count,
};
getToken(data);
})
.catch(error => {
console.log(error);
});
} else {
setCount(count + 1);
setModalVisible3(true);
startRecording();
}
console.log('count', count);
};
const onSpeechError = e => {
console.log('onSpeechError: ', e);
const result = DummyReadResult.value;
if (result.includes('hello')) {
if (result.includes('helloddd')) {
AsyncStorage.getItem('userId')
.then(userId => {
const data = {
......@@ -84,11 +182,9 @@ export default function ReadActivityNo() {
} else {
setCount(count + 1);
setModalVisible3(true);
Voice.start('en-US');
console.log(count);
startRecording();
}
console.log('count', count);
console.log('count', count);
};
const getToken = data => {
......@@ -121,11 +217,8 @@ export default function ReadActivityNo() {
)}
{modalVisible3 && (
<ReadModal
caption="Misronunciation"
validity="Please Try Again."
<ReadModalFailed
visible="true"
path="ReadActivityGo"
/>
)}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment