Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
240
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
U.D.C.S.WIJESOORIYA
240
Commits
88281141
Commit
88281141
authored
Aug 05, 2022
by
Malsha Rathnasiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issues
parent
7108789d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
19 additions
and
10 deletions
+19
-10
.gitignore
.gitignore
+6
-0
MobileApp/components/AudioRecorder.jsx
MobileApp/components/AudioRecorder.jsx
+1
-1
backend/all_label.txt
backend/all_label.txt
+0
-0
backend/backend/cms/model/predict.py
backend/backend/cms/model/predict.py
+6
-6
backend/backend/cms/model/train.py
backend/backend/cms/model/train.py
+3
-0
backend/backend/cms/views.py
backend/backend/cms/views.py
+3
-3
backend/db.sqlite3
backend/db.sqlite3
+0
-0
backend/db_old2.sqlite3
backend/db_old2.sqlite3
+0
-0
requirements.txt
requirements.txt
+0
-0
No files found.
.gitignore
View file @
88281141
venv/
venv/
backend/output.wav
backend/backend/output.m4a
ffmpeg-2022-08-03-git-d3f48e68b3-essentials_build/ffmpeg.exe
ngrok.exe
ffmpeg-2022-08-03-git-d3f48e68b3-essentials_build/ffplay.exe
ffmpeg-2022-08-03-git-d3f48e68b3-essentials_build/ffprobe.exe
MobileApp/components/AudioRecorder.jsx
View file @
88281141
...
@@ -49,7 +49,7 @@ export const AudioRecorder = ({ setDetectedText }) => {
...
@@ -49,7 +49,7 @@ export const AudioRecorder = ({ setDetectedText }) => {
}
}
playSound
(
uri
)
playSound
(
uri
)
FileSystem
.
uploadAsync
(
"
https://
1ec4-112-134-210-155.ap
.ngrok.io/mlmodels/detect/
"
,
uri
,
{
headers
:
headers
,
uploadType
:
FileSystem
.
FileSystemUploadType
.
MULTIPART
})
FileSystem
.
uploadAsync
(
"
https://
ebf4-2401-dd00-10-20-4ca2-920b-4150-8178.in
.ngrok.io/mlmodels/detect/
"
,
uri
,
{
headers
:
headers
,
uploadType
:
FileSystem
.
FileSystemUploadType
.
MULTIPART
})
.
then
(
data
=>
JSON
.
parse
(
data
.
body
))
.
then
(
data
=>
JSON
.
parse
(
data
.
body
))
.
then
(
data
=>
{
console
.
log
({
result
:
data
});
setDetectedText
(
data
.
result
);
setTimeout
(()
=>
setDetectedText
(
''
),
1000
)
})
.
then
(
data
=>
{
console
.
log
({
result
:
data
});
setDetectedText
(
data
.
result
);
setTimeout
(()
=>
setDetectedText
(
''
),
1000
)
})
.
catch
(
err
=>
console
.
log
({
err
}))
.
catch
(
err
=>
console
.
log
({
err
}))
...
...
backend/all_label.txt
0 → 100644
View file @
88281141
File added
backend/backend/cms/model/predict.py
View file @
88281141
...
@@ -20,17 +20,17 @@ def predict(samples):
...
@@ -20,17 +20,17 @@ def predict(samples):
all_label
=
pickle
.
load
(
f1
)
all_label
=
pickle
.
load
(
f1
)
print
(
'loaded labels'
)
print
(
'loaded labels'
)
f2
=
open
(
'all_waves_file.txt'
,
'rb'
)
#
f2 = open('all_waves_file.txt', 'rb')
all_wave
=
pickle
.
load
(
f2
)
#
all_wave = pickle.load(f2)
print
(
'loaded waves'
)
#
print('loaded waves')
le
=
LabelEncoder
()
le
=
LabelEncoder
()
y
=
le
.
fit_transform
(
all_label
)
y
=
le
.
fit_transform
(
all_label
)
classes
=
list
(
le
.
classes_
)
classes
=
list
(
le
.
classes_
)
train_data_file
=
open
(
"train_data_file.txt"
,
'rb'
)
#
train_data_file = open("train_data_file.txt", 'rb')
[
x_tr
,
x_val
,
y_tr
,
y_val
]
=
np
.
load
(
train_data_file
,
allow_pickle
=
True
)
#
[x_tr, x_val, y_tr, y_val] = np.load(train_data_file, allow_pickle=True)
train_data_file
.
close
()
#
train_data_file.close()
def
predictSamples
(
audio
):
def
predictSamples
(
audio
):
prob
=
model
.
predict
(
audio
.
reshape
(
1
,
8000
,
1
))
prob
=
model
.
predict
(
audio
.
reshape
(
1
,
8000
,
1
))
...
...
backend/backend/cms/model/train.py
View file @
88281141
...
@@ -128,12 +128,15 @@ def train():
...
@@ -128,12 +128,15 @@ def train():
pickle
.
dump
(
file
=
all_labels_file
,
obj
=
all_label
)
pickle
.
dump
(
file
=
all_labels_file
,
obj
=
all_label
)
all_labels_file
.
close
()
all_labels_file
.
close
()
return
False
all_waves_file
=
open
(
'all_waves_file.txt'
,
'wb+'
)
all_waves_file
=
open
(
'all_waves_file.txt'
,
'wb+'
)
pickle
.
dump
(
file
=
all_waves_file
,
obj
=
all_wave
)
pickle
.
dump
(
file
=
all_waves_file
,
obj
=
all_wave
)
all_waves_file
.
close
()
all_waves_file
.
close
()
print
(
'Done: creating labels and waves files'
)
print
(
'Done: creating labels and waves files'
)
return
False
le
=
LabelEncoder
()
le
=
LabelEncoder
()
y
=
le
.
fit_transform
(
all_label
)
y
=
le
.
fit_transform
(
all_label
)
classes
=
list
(
le
.
classes_
)
classes
=
list
(
le
.
classes_
)
...
...
backend/backend/cms/views.py
View file @
88281141
...
@@ -26,7 +26,6 @@ from .model.predict import predict
...
@@ -26,7 +26,6 @@ from .model.predict import predict
from
pydub
import
AudioSegment
from
pydub
import
AudioSegment
import
numpy
as
np
import
numpy
as
np
class
UserViewSet
(
viewsets
.
ModelViewSet
):
class
UserViewSet
(
viewsets
.
ModelViewSet
):
"""
"""
API endpoint that allows users to be viewed or edited.
API endpoint that allows users to be viewed or edited.
...
@@ -80,7 +79,8 @@ class MlModelViewSet(viewsets.ViewSet):
...
@@ -80,7 +79,8 @@ class MlModelViewSet(viewsets.ViewSet):
with
open
(
"output.m4a"
,
"wb"
)
as
f
:
with
open
(
"output.m4a"
,
"wb"
)
as
f
:
f
.
write
(
bytesio_object
.
getbuffer
())
f
.
write
(
bytesio_object
.
getbuffer
())
path
=
os
.
path
.
abspath
(
"output.m4a"
)
print
(
path
)
# convert wav to mp3
# convert wav to mp3
audSeg
=
AudioSegment
.
from_file
(
"output.m4a"
)
audSeg
=
AudioSegment
.
from_file
(
"output.m4a"
)
audSeg
.
export
(
'output.wav'
,
format
=
"wav"
)
audSeg
.
export
(
'output.wav'
,
format
=
"wav"
)
...
@@ -97,7 +97,7 @@ class MlModelViewSet(viewsets.ViewSet):
...
@@ -97,7 +97,7 @@ class MlModelViewSet(viewsets.ViewSet):
print
(
samples
.
shape
)
print
(
samples
.
shape
)
else
:
else
:
len
=
8000
-
samples
.
shape
[
0
]
len
=
8000
-
samples
.
shape
[
0
]
new_arr
=
np
.
zero
e
s
(
len
,
)
new_arr
=
np
.
zeros
(
len
,
)
samples
=
np
.
concatenate
((
samples
,
new_arr
))
samples
=
np
.
concatenate
((
samples
,
new_arr
))
print
(
samples
.
shape
)
print
(
samples
.
shape
)
...
...
backend/db.sqlite3
View file @
88281141
No preview for this file type
backend/db_old2.sqlite3
0 → 100644
View file @
88281141
File added
requirements.txt
View file @
88281141
B
absl-py
==1.2.0
B
absl-py
==1.2.0
...
...
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