Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
21_22-J 38
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 38
21_22-J 38
Commits
28cba3bb
Commit
28cba3bb
authored
May 01, 2022
by
Lihinikaduwa D.N.R.
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'it18257632' into 'master'
It18257632 See merge request
!174
parents
6ba28c5f
93e39e4e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
60 deletions
+85
-60
API/app.py
API/app.py
+3
-5
API/model/__pycache__/readModel.cpython-39.pyc
API/model/__pycache__/readModel.cpython-39.pyc
+0
-0
API/model/readModel.py
API/model/readModel.py
+3
-3
frontend/src/component/reading/ReadCategory.js
frontend/src/component/reading/ReadCategory.js
+18
-5
frontend/src/screen/auth/Login.js
frontend/src/screen/auth/Login.js
+2
-1
frontend/src/screen/client/Client.js
frontend/src/screen/client/Client.js
+1
-1
frontend/src/screen/reading/advanced/ReadActivityBird.js
frontend/src/screen/reading/advanced/ReadActivityBird.js
+1
-8
frontend/src/screen/reading/basic/ReadActivityNo.js
frontend/src/screen/reading/basic/ReadActivityNo.js
+57
-37
No files found.
API/app.py
View file @
28cba3bb
...
...
@@ -193,9 +193,7 @@ def logout():
@
app
.
route
(
"/readingSession"
,
methods
=
[
'POST'
])
def
reading_session
():
req
=
request
.
get_json
()
userId
=
req
[
'userId'
]
token
=
save_session_details
(
userId
,
1
)
token
=
save_session_details
(
1
)
response
=
{
"token"
:
token
,
"message"
:
"Success"
,
...
...
@@ -219,7 +217,7 @@ def reading_session_status_update(readingToken):
@
app
.
route
(
"/reading/<readingToken>"
,
methods
=
[
'POST'
])
def
reading
(
readingToken
):
def
save_
reading
(
readingToken
):
assert
readingToken
==
request
.
view_args
[
'readingToken'
]
token
=
readingToken
req
=
request
.
get_json
()
...
...
@@ -237,4 +235,4 @@ def reading(readingToken):
if
__name__
==
"__main__"
:
app
.
run
(
host
=
'192.168.1.10
0
'
)
app
.
run
(
host
=
'192.168.1.10
1
'
)
API/model/__pycache__/readModel.cpython-39.pyc
View file @
28cba3bb
No preview for this file type
API/model/readModel.py
View file @
28cba3bb
...
...
@@ -27,10 +27,10 @@ def save_activity_details(userId, word, token, level, triedCount):
return
result
def
save_session_details
(
userId
,
status
):
def
save_session_details
(
status
):
token
=
getUUID
()
qry
=
'INSERT INTO readingSession (id,
userId,token,status) VALUES (NULL,
%
s
,
%
s,
%
s)'
args
=
(
userId
,
token
,
status
)
qry
=
'INSERT INTO readingSession (id,
token,status) VALUES (NULL
,
%
s,
%
s)'
args
=
(
token
,
status
)
insert
(
qry
,
args
)
return
token
...
...
frontend/src/component/reading/ReadCategory.js
View file @
28cba3bb
...
...
@@ -17,11 +17,24 @@ const ReadCategory = props => {
const
navigation
=
useNavigation
();
const
checkReadingSession
=
()
=>
{
AsyncStorage
.
getItem
(
'
readingSession
'
)
.
then
(
value
=>
{
if
(
value
==
null
)
{
console
.
log
(
'
bfxcvbfvfdxv
'
,
value
);
getReadingSession
(
value
);
}
else
{
console
.
log
(
'
bfxcvbfvfdxv
'
);
navigation
.
navigate
(
path
);
}
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
};
const
getReadingSession
=
()
=>
{
const
data
=
{
userId
:
1
,
};
Client
.
post
(
'
readingSession
'
,
JSON
.
stringify
(
data
),
{
Client
.
post
(
'
readingSession
'
,
{
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
...
...
@@ -49,7 +62,7 @@ const ReadCategory = props => {
<
View
style
=
{
styles
.
gameItem
}
>
<
TouchableOpacity
onPress
=
{()
=>
{
get
ReadingSession
();
check
ReadingSession
();
}}
>
<
View
>
{
/* <View style={{...styles.gameItemRow, ...styles.gameItemHeader}}> */
}
...
...
frontend/src/screen/auth/Login.js
View file @
28cba3bb
...
...
@@ -74,6 +74,7 @@ const Login = () => {
};
const
submitForm
=
()
=>
{
AsyncStorage
.
setItem
(
'
userId
'
,
'
1
'
);
navigation
.
navigate
(
'
Start
'
);
// if (isValidForm()) {
// loginFun(userInfo);
...
...
@@ -100,7 +101,7 @@ const Login = () => {
const
userToken
=
res
.
data
.
token
;
const
userId
=
res
.
data
.
userId
;
AsyncStorage
.
setItem
(
'
userToken
'
,
userToken
);
AsyncStorage
.
setItem
(
'
userId
'
,
userId
);
AsyncStorage
.
setItem
(
'
userId
'
,
1
);
return
navigation
.
navigate
(
'
Start
'
);
}
})
...
...
frontend/src/screen/client/Client.js
View file @
28cba3bb
...
...
@@ -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.1.10
0
:5000/
'
,
baseURL
:
'
http://192.168.1.10
1
:5000/
'
,
timeout
:
15000
,
});
frontend/src/screen/reading/advanced/ReadActivityBird.js
View file @
28cba3bb
...
...
@@ -14,7 +14,7 @@ import {
TouchableHighlight
,
}
from
'
react-native
'
;
import
Voice
from
'
@react-native-voice/voice
'
;
import
{
DummyReadResult
}
from
'
../../../assets/read/data/ReadData
'
;
import
{
DummyReadResult
,
ImagePaths
}
from
'
../../../assets/read/data/ReadData
'
;
import
AudioRecord
from
'
react-native-audio-record
'
;
import
Client
from
'
../../client/Client
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
...
...
@@ -24,7 +24,6 @@ export default function ReadActivityBird() {
// const userToken = Authorize();
const
navigation
=
useNavigation
();
const
[
error
,
setError
]
=
useState
(
''
);
const
[
readingData
,
setReadingData
]
=
useState
({
activity
:
''
});
// let user = AsyncStorage.getItem('readingSession');
// useEffect(() => {
...
...
@@ -34,7 +33,6 @@ export default function ReadActivityBird() {
useEffect
(()
=>
{
Voice
.
onSpeechStart
=
onSpeechStartHandler
;
Voice
.
onSpeechEnd
=
onSpeechEndHandler
;
Voice
.
onSpeechResults
=
onSpeechResultsHandler
;
Voice
.
onSpeechError
=
onSpeechError
;
...
...
@@ -75,16 +73,11 @@ export default function ReadActivityBird() {
console
.
log
(
'
start handler =>>
'
,
e
);
};
const
onSpeechEndHandler
=
e
=>
{
console
.
log
(
'
end handler =>>
'
,
e
);
};
const
onSpeechResultsHandler
=
e
=>
{
console
.
log
(
'
result handler =>>
'
,
e
);
};
const
onSpeechError
=
e
=>
{
setError
(
JSON
.
stringify
(
e
.
error
));
const
result
=
DummyReadResult
.
value
;
const
data
=
{
word
:
'
bird
'
,
...
...
frontend/src/screen/reading/basic/ReadActivityNo.js
View file @
28cba3bb
...
...
@@ -15,40 +15,60 @@ import {
}
from
'
react-native
'
;
import
Voice
from
'
@react-native-voice/voice
'
;
import
{
DummyReadResult
,
ImagePaths
}
from
'
../../../assets/read/data/ReadData
'
;
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
{
Authorize
}
from
'
../../auth/AuthenticateUser
'
;
import
Client
from
'
../../client/Client
'
;
export
default
function
ReadActivityNo
()
{
const
navigation
=
useNavigation
();
const
[
pitch
,
setPitch
]
=
useState
(
''
);
const
[
error
,
setError
]
=
useState
(
''
);
const
[
end
,
setEnd
]
=
useState
(
''
);
const
[
started
,
setStarted
]
=
useState
(
''
);
const
[
results
,
setResults
]
=
useState
([]);
const
[
partialResults
,
setPartialResults
]
=
useState
([]);
useEffect
(()
=>
{
Voice
.
destroy
().
then
(
Voice
.
removeAllListeners
);
},
[]);
const
[
readingData
,
setReadingData
]
=
useState
({
word
:
''
,
userId
:
''
,
level
:
1
,
triedCount
:
1
,
});
const
[
count
,
setCount
]
=
useState
(
1
);
useEffect
(()
=>
{
Voice
.
onSpeechStart
=
onSpeechStartHandler
;
Voice
.
onSpeechEnd
=
onSpeechEndHandler
;
Voice
.
onSpeechResults
=
onSpeechResultsHandler
;
Voice
.
onSpeechError
=
onSpeechError
;
Voice
.
onSpeechPartialResults
=
onSpeechPartialResults
;
Voice
.
onSpeechVolumeChanged
=
onSpeechVolumeChanged
;
return
()
=>
{
Voice
.
destroy
().
then
(
Voice
.
removeAllListeners
);
};
},
[]);
const
onSpeechStartHandler
=
e
=>
{
console
.
log
(
'
start handler =>>
'
,
e
);
const
getToken
=
data
=>
{
AsyncStorage
.
getItem
(
'
readingSession
'
)
.
then
(
readingSession
=>
{
sendRedingData
(
data
,
readingSession
);
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
};
const
onSpeechEndHandler
=
e
=>
{
console
.
log
(
'
end handler =>>
'
,
e
);
const
sendRedingData
=
(
data
,
readingSession
)
=>
{
Client
.
post
(
'
reading/
'
+
readingSession
,
JSON
.
stringify
(
data
),
{
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
},
})
.
then
(
res
=>
{
console
.
log
(
res
.
data
);
// AsyncStorage.removeItem('readingSession');
navigation
.
navigate
(
'
ReadActivityGo
'
);
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
};
const
onSpeechStartHandler
=
e
=>
{
console
.
log
(
'
start handler =>>
'
,
e
);
};
const
onSpeechResultsHandler
=
e
=>
{
...
...
@@ -57,23 +77,31 @@ export default function ReadActivityNo() {
const
onSpeechError
=
e
=>
{
console
.
log
(
'
onSpeechError:
'
,
e
);
setError
(
JSON
.
stringify
(
e
.
error
));
const
result
=
DummyReadResult
.
value
;
if
(
result
.
includes
(
'
hello
'
))
{
console
.
log
(
'
correct
'
);
navigation
.
navigate
(
'
ReadActivityGo
'
);
AsyncStorage
.
getItem
(
'
userId
'
)
.
then
(
userId
=>
{
const
data
=
{
word
:
'
no
'
,
userId
:
userId
,
level
:
1
,
triedCount
:
count
,
};
console
.
log
(
'
correct
'
,
data
);
getToken
(
data
);
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
}
else
{
setCount
(
count
+
1
);
Voice
.
start
(
'
en-US
'
);
}
};
const
onSpeechPartialResults
=
e
=>
{
console
.
log
(
'
onSpeechPartialResults:
'
,
e
);
setPartialResults
(
e
.
value
);
};
console
.
log
(
'
count
'
,
count
);
const
onSpeechVolumeChanged
=
e
=>
{
console
.
log
(
'
onSpeechVolumeChanged:
'
,
e
);
setPitch
(
e
.
value
);
console
.
log
(
'
count
'
,
count
);
};
const
startRecording
=
async
()
=>
{
...
...
@@ -84,14 +112,6 @@ export default function ReadActivityNo() {
}
};
const
stopRecording
=
async
()
=>
{
try
{
await
Voice
.
stop
();
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
return
(
<
SafeAreaView
>
<
View
style
=
{{
flexDirection
:
'
column
'
}}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment