Commit 2294ffe2 authored by W.D.R.P. Sandeepa's avatar W.D.R.P. Sandeepa

Merge branch 'it18218640' into 'master'

change activity interface

See merge request !140
parents 33fe1ad6 5b597f99
...@@ -13,7 +13,6 @@ from API.routers.router import funtion_one ...@@ -13,7 +13,6 @@ from API.routers.router import funtion_one
app = Flask(__name__) app = Flask(__name__)
# Initial Route # Initial Route
@app.route("/") @app.route("/")
def home(): def home():
...@@ -46,6 +45,8 @@ def home(): ...@@ -46,6 +45,8 @@ def home():
# return msg # return msg
# Color Function Route (IT18218640) # Color Function Route (IT18218640)
# Get Color activities route
@app.route("/getColorActivities1") @app.route("/getColorActivities1")
def getColorActivities1(): def getColorActivities1():
return get_color_activities1() return get_color_activities1()
...@@ -100,17 +101,11 @@ def getColorActivitiesResult(): ...@@ -100,17 +101,11 @@ def getColorActivitiesResult():
# Read Function Route (IT) # Read Function Route (IT)
@app.route("/testings") @app.route("/testings")
def checkothers(): def checkothers():
return "testing funtions" return "testing funtions"
# Color Function Route (IT18218640)
@app.route("/reading")
def getReadActivities():
return get_reading_activities()
@app.route("/ru") @app.route("/ru")
def abc(): def abc():
response_val = funtion_one() response_val = funtion_one()
...@@ -146,4 +141,4 @@ def login(): ...@@ -146,4 +141,4 @@ def login():
if __name__ == "__main__": if __name__ == "__main__":
# app.run(host='192.168.8.101') # app.run(host='192.168.8.101')
# app.run(host='192.168.8.100,port='5000', debug=True) # app.run(host='192.168.8.100,port='5000', debug=True)
app.run(debug=True) app.run(debug=True)
\ No newline at end of file
File added
import { import { useNavigation } from "@react-navigation/native";
useNavigation
} from "@react-navigation/native";
import Orientation from 'react-native-orientation-locker'; import Orientation from 'react-native-orientation-locker';
import React, { import React, { useEffect, useState } from "react";
useEffect, import { Text,TouchableOpacity, StyleSheet, View, Dimensions, SafeAreaView, ImageBackground, Button, Image, StatusBar} from 'react-native'
useState
} from "react";
import {
Text,
TouchableOpacity,
StyleSheet,
View,
Dimensions,
SafeAreaView,
ImageBackground,
Button,
Image,
StatusBar
} from 'react-native'
import Permissions from 'react-native-permissions'; import Permissions from 'react-native-permissions';
import AudioRecord from 'react-native-audio-record'; import AudioRecord from 'react-native-audio-record';
import axios from "axios"; import axios from "axios";
import client from "../client/Client"; import client from "../client/Client";
import BackButton from "../../component/BackButton"
export default function Blue(color) { export default function Blue(color) {
const navigation = useNavigation(); const navigation = useNavigation();
...@@ -46,7 +31,6 @@ export default function Blue(color) { ...@@ -46,7 +31,6 @@ export default function Blue(color) {
return unsubscribe; return unsubscribe;
}, [navigation]); }, [navigation]);
// audioInit
function audioInit() { function audioInit() {
// console.log('audioInit'); // console.log('audioInit');
...@@ -61,10 +45,9 @@ export default function Blue(color) { ...@@ -61,10 +45,9 @@ export default function Blue(color) {
AudioRecord.init(colorAudio); AudioRecord.init(colorAudio);
} }
// checkPermission
async function checkPermission() { async function checkPermission() {
// console.log('checkPermission'); // console.log('checkPermission');
const p = await Permissions.check('microphone'); const p = await Permissions.check('microphone');
// console.log(p); // console.log(p);
// console.log('permission check', p); // console.log('permission check', p);
...@@ -79,13 +62,11 @@ export default function Blue(color) { ...@@ -79,13 +62,11 @@ export default function Blue(color) {
} }
// requestPermission
async function requestPermission() { async function requestPermission() {
const p = await Permissions.request('microphone'); const p = await Permissions.request('microphone');
// console.log('permission request', p); // console.log('permission request', p);
} }
// audioStart
async function audioStart() { async function audioStart() {
// console.log('audioStart'); // console.log('audioStart');
...@@ -96,7 +77,6 @@ export default function Blue(color) { ...@@ -96,7 +77,6 @@ export default function Blue(color) {
}, 2000); }, 2000);
} }
// audioStop
async function audioStop() { async function audioStop() {
// console.log('audioStop'); // console.log('audioStop');
...@@ -104,12 +84,66 @@ export default function Blue(color) { ...@@ -104,12 +84,66 @@ export default function Blue(color) {
let audioFile = await AudioRecord.stop(); let audioFile = await AudioRecord.stop();
console.log('userFile', audioFile); console.log('userFile', audioFile);
//call sendAudio funtion // sendAudio(audioFile);
sendAudio(audioFile); getAudio(audioFile);
} }
// send audio to server function function getAudio(audioFile) {
const formData = new FormData();
var obj = {
uri: `file://${audioFile}`,
type: 'audio/wav',
name: 'color.wav',
colorNmae: backColor
}
// formData.append(
// 'file',
// {
// uri: `file://${audioFile}`,
// type: 'audio/wav',
// name: 'color.wav',
// }
// );
// formData.append(
// 'name', backColor
// );
var data = JSON.stringify(obj)
console.log(data);
axios
.post("http://192.168.8.102:5000/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);
});
}
async function sendAudio(audioFile) { async function sendAudio(audioFile) {
// append form data and upload to api // append form data and upload to api
...@@ -193,16 +227,34 @@ export default function Blue(color) { ...@@ -193,16 +227,34 @@ export default function Blue(color) {
</View> </View>
<View style={{ flexDirection: "row", marginLeft: 480 }}> <View style={{ marginTop: 10 }}>
<Button style={styles.button} title="Recode" onPress={() => { audioStart(); }} /> <BackButton path="Color" />
<Button title="Return" color="#1DCE92" /> </View>
<Button title="Exit" color="#841584" />
<View style={{ flexDirection: "row", marginLeft: 420, marginTop: -80 }}>
<View style={{}}>
<TouchableOpacity onPress={() => { audioStart(); }}
style={{ width: "30%", height: "40%", borderRadius: 50 }}>
<Image source={require('../../assets/game/mic2.png')} resizeMode='contain' style={{ flex: 1, marginLeft: -190 }} />
</TouchableOpacity>
</View>
<View style={{ marginLeft: -100 }}>
<TouchableOpacity onPress={() => { }}
style={{ width: "60%", height: "40%", borderRadius: 50 }}>
<Image source={require('../../assets/game/next.png')} resizeMode='contain' style={{ flex: .9, marginLeft: -90 }} />
</TouchableOpacity>
</View>
</View> </View>
</ImageBackground> </ImageBackground>
</View> </View>
</SafeAreaView> </SafeAreaView>
) )
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
...@@ -244,7 +296,8 @@ const styles = StyleSheet.create({ ...@@ -244,7 +296,8 @@ const styles = StyleSheet.create({
button: { button: {
padding: 10, padding: 10,
marginRight: 50, marginRight: 50,
color: "#000000" color: "#000000",
marginLeft: 50,
} }
}) })
\ No newline at end of file
...@@ -93,13 +93,13 @@ const Login = () => { ...@@ -93,13 +93,13 @@ const Login = () => {
</View> </View>
<View style={styles.form_input}> <View style={styles.form_input}>
<TouchableOpacity onPress={submitForm} style={styles.btn}> <TouchableOpacity onPress={()=> { navigation.navigate("Home")}} style={styles.btn}>
<Text style={styles.btn_text}> <Text style={styles.btn_text}>
Sign In Sign In
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
{/* onPress={submitForm} */}
<View style={styles.text_if}> <View style={styles.text_if}>
<TouchableOpacity onPress={()=> { navigation.navigate("Register")}}> <TouchableOpacity onPress={()=> { navigation.navigate("Register")}}>
<Text style={styles.btn_text2}> <Text style={styles.btn_text2}>
......
...@@ -86,6 +86,8 @@ const Register = () => { ...@@ -86,6 +86,8 @@ const Register = () => {
} }
} }
// import client from "../client/Client";
return ( return (
<SafeAreaView> <SafeAreaView>
<ScrollView> <ScrollView>
......
import axios from 'axios'; import axios from 'axios';
export default axios.create({ baseURL: 'http://192.168.8.101:5000/',timeout: 15000, }); export default axios.create({ baseURL: 'http://192.168.8.102:5000/',timeout: 15000, });
\ No newline at end of file \ No newline at end of file
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