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
3c577846
Commit
3c577846
authored
Feb 11, 2022
by
W.D.R.P. Sandeepa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change route
parent
7f09f8f5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
13 deletions
+56
-13
API/__pycache__/keyword_spotting_service.cpython-39.pyc
API/__pycache__/keyword_spotting_service.cpython-39.pyc
+0
-0
API/app.py
API/app.py
+40
-1
backend/IT18218640/__pycache__/keyword_spotting_service.cpython-39.pyc
...18640/__pycache__/keyword_spotting_service.cpython-39.pyc
+0
-0
backend/IT18218640/client.py
backend/IT18218640/client.py
+1
-1
backend/IT18218640/keyword_spotting_service.py
backend/IT18218640/keyword_spotting_service.py
+3
-1
backend/IT18218640/model.h5
backend/IT18218640/model.h5
+0
-0
backend/IT18218640/server.py
backend/IT18218640/server.py
+12
-10
No files found.
API/__pycache__/keyword_spotting_service.cpython-39.pyc
0 → 100644
View file @
3c577846
File added
API/app.py
View file @
3c577846
from
flask
import
Flask
,
redirect
,
url_for
,
render_template
,
request
,
jsonify
,
make_response
import
random
import
os
from
API.model.colorModel
import
get_color_activities
,
get_color_activity_result
from
API.model.readModel
import
get_reading_activities
from
API.routers.router
import
funtion_one
from
backend.IT18218640.keyword_spotting_service
import
Keyword_Spotting_service
app
=
Flask
(
__name__
)
...
...
@@ -23,6 +25,43 @@ def getColorActivitiesResult():
# print("data_dic")
return
get_color_activity_result
()
@
app
.
route
(
"/predict"
,
methods
=
[
"POST"
])
def
predict
():
# get audio file and save it
audio_file
=
request
.
files
[
"file"
]
print
(
f
"{request.files['file']}"
)
# print(f"{request.files['name']}")
######################################
print
(
f
"{request.form['name']}"
)
#####################################
# print(f"{request.json}")
file_name
=
str
(
random
.
randint
(
0
,
100000
))
# audio_file.save((file_name))
# get file name
# predict_file_name = audio_file.filename
# predict_file_name = predict_file_name.split("/")
# new_predict_file_name = predict_file_name[1]
# new_predict_file_name = new_predict_file_name.split(".")
# FPFN = new_predict_file_name[0]
# print(f"{FPFN}")
# invoke keyword spotting service
kss
=
Keyword_Spotting_service
()
# make a prediction
predicted_keyword
=
kss
.
predict
(
file_name
,
request
.
form
[
'name'
])
# remove the audio file
os
.
remove
(
file_name
)
# send back the predicted keword in json format
data
=
{
"Keyword"
:
predicted_keyword
}
return
jsonify
(
data
)
# return "audio_file"
# Read Function Route (IT)
...
...
backend/IT18218640/__pycache__/keyword_spotting_service.cpython-39.pyc
View file @
3c577846
No preview for this file type
backend/IT18218640/client.py
View file @
3c577846
import
requests
URL
=
"http://192.168.8.10
1
:5000/predict"
URL
=
"http://192.168.8.10
0
:5000/predict"
TEST_AUDIO_FILE_PATH
=
"test/red.wav"
if
__name__
==
"__main__"
:
...
...
backend/IT18218640/keyword_spotting_service.py
View file @
3c577846
...
...
@@ -17,9 +17,11 @@ class _Keyword_Spotting_Service:
"yellow"
]
_instance
=
None
# 78293
def
predict
(
self
,
file_path
,
FPFN
):
print
(
f
"{file_path}"
)
# extract MFCCs
MFCCs
=
self
.
preprocess
(
file_path
)
# (# segment, # coefficients)
...
...
backend/IT18218640/model.h5
View file @
3c577846
No preview for this file type
backend/IT18218640/server.py
View file @
3c577846
...
...
@@ -7,25 +7,26 @@ app = Flask(__name__)
@
app
.
route
(
"/predict"
,
methods
=
[
"POST"
])
def
predict
():
# get audio file and save it
audio_file
=
request
.
files
[
"file"
]
# print(f"{request.files['file']}")
# print(f"{request.files['name']}")
file_name
=
str
(
random
.
randint
(
0
,
100000
))
audio_file
.
save
((
file_name
))
# get file name
predict_file_name
=
audio_file
.
filename
predict_file_name
=
predict_file_name
.
split
(
"/"
)
new_predict_file_name
=
predict_file_name
[
1
]
new_predict_file_name
=
new_predict_file_name
.
split
(
"."
)
FPFN
=
new_predict_file_name
[
0
]
# predict_file_name = audio_file.filename
# predict_file_name = predict_file_name.split("/")
# new_predict_file_name = predict_file_name[1]
# new_predict_file_name = new_predict_file_name.split(".")
# FPFN = new_predict_file_name[0]
FPFN
=
request
.
form
[
'name'
]
# print(f"{FPFN}")
# invoke keyword spotting service
kss
=
Keyword_Spotting_service
()
# make a prediction
predicted_keyword
=
kss
.
predict
(
file_name
,
FPFN
)
...
...
@@ -33,10 +34,11 @@ def predict():
os
.
remove
(
file_name
)
# send back the predicted keword in json format
data
=
{
"Keyword"
:
predicted_keyword
}
data
=
{
"Keyword"
:
predicted_keyword
}
return
jsonify
(
data
)
if
__name__
==
"__main__"
:
app
.
run
(
host
=
'192.168.8.10
1
'
)
app
.
run
(
host
=
'192.168.8.10
0
'
)
#app.run(host='192.168.8.100,port='5000', debug=True)
# app.run(debug=False)
\ No newline at end of file
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