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
app = Flask(__name__)
# Initial Route
@app.route("/")
def home():
......@@ -46,6 +45,8 @@ def home():
# return msg
# Color Function Route (IT18218640)
# Get Color activities route
@app.route("/getColorActivities1")
def getColorActivities1():
return get_color_activities1()
......@@ -100,17 +101,11 @@ def getColorActivitiesResult():
# Read Function Route (IT)
@app.route("/testings")
def checkothers():
return "testing funtions"
# Color Function Route (IT18218640)
@app.route("/reading")
def getReadActivities():
return get_reading_activities()
@app.route("/ru")
def abc():
response_val = funtion_one()
......@@ -146,4 +141,4 @@ def login():
if __name__ == "__main__":
# app.run(host='192.168.8.101')
# 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 {
useNavigation
} from "@react-navigation/native";
import { useNavigation } from "@react-navigation/native";
import Orientation from 'react-native-orientation-locker';
import React, {
useEffect,
useState
} from "react";
import {
Text,
TouchableOpacity,
StyleSheet,
View,
Dimensions,
SafeAreaView,
ImageBackground,
Button,
Image,
StatusBar
} from 'react-native'
import React, { useEffect, useState } from "react";
import { Text,TouchableOpacity, StyleSheet, View, Dimensions, SafeAreaView, ImageBackground, Button, Image, StatusBar} from 'react-native'
import Permissions from 'react-native-permissions';
import AudioRecord from 'react-native-audio-record';
import axios from "axios";
import client from "../client/Client";
import BackButton from "../../component/BackButton"
export default function Blue(color) {
const navigation = useNavigation();
......@@ -46,7 +31,6 @@ export default function Blue(color) {
return unsubscribe;
}, [navigation]);
// audioInit
function audioInit() {
// console.log('audioInit');
......@@ -61,10 +45,9 @@ export default function Blue(color) {
AudioRecord.init(colorAudio);
}
// checkPermission
async function checkPermission() {
// console.log('checkPermission');
const p = await Permissions.check('microphone');
// console.log(p);
// console.log('permission check', p);
......@@ -79,13 +62,11 @@ export default function Blue(color) {
}
// requestPermission
async function requestPermission() {
const p = await Permissions.request('microphone');
// console.log('permission request', p);
}
// audioStart
async function audioStart() {
// console.log('audioStart');
......@@ -96,7 +77,6 @@ export default function Blue(color) {
}, 2000);
}
// audioStop
async function audioStop() {
// console.log('audioStop');
......@@ -104,12 +84,66 @@ export default function Blue(color) {
let audioFile = await AudioRecord.stop();
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) {
// append form data and upload to api
......@@ -193,16 +227,34 @@ export default function Blue(color) {
</View>
<View style={{ flexDirection: "row", marginLeft: 480 }}>
<Button style={styles.button} title="Recode" onPress={() => { audioStart(); }} />
<Button title="Return" color="#1DCE92" />
<Button title="Exit" color="#841584" />
<View style={{ marginTop: 10 }}>
<BackButton path="Color" />
</View>
<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>
</ImageBackground>
</View>
</SafeAreaView>
)
}
const styles = StyleSheet.create({
......@@ -244,7 +296,8 @@ const styles = StyleSheet.create({
button: {
padding: 10,
marginRight: 50,
color: "#000000"
color: "#000000",
marginLeft: 50,
}
})
\ No newline at end of file
......@@ -93,13 +93,13 @@ const Login = () => {
</View>
<View style={styles.form_input}>
<TouchableOpacity onPress={submitForm} style={styles.btn}>
<TouchableOpacity onPress={()=> { navigation.navigate("Home")}} style={styles.btn}>
<Text style={styles.btn_text}>
Sign In
</Text>
</TouchableOpacity>
</View>
{/* onPress={submitForm} */}
<View style={styles.text_if}>
<TouchableOpacity onPress={()=> { navigation.navigate("Register")}}>
<Text style={styles.btn_text2}>
......
......@@ -86,6 +86,8 @@ const Register = () => {
}
}
// import client from "../client/Client";
return (
<SafeAreaView>
<ScrollView>
......
import axios from 'axios';
export default axios.create({ baseURL: 'http://192.168.8.101:5000/',timeout: 15000, });
\ No newline at end of file
export default axios.create({ baseURL: 'http://192.168.8.102:5000/',timeout: 15000, });
\ 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