Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
Easy Quest - Smart Recruitment Tool with AI - Backend
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
22_23 - J 36
Easy Quest - Smart Recruitment Tool with AI - Backend
Commits
346ad209
Commit
346ad209
authored
Apr 15, 2023
by
Emika Chamodi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Voice analys timeout
parent
d746cccc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
14 deletions
+102
-14
NodeServer/src/routes/application.ts
NodeServer/src/routes/application.ts
+31
-5
NodeServer/src/routes/user.ts
NodeServer/src/routes/user.ts
+8
-5
PythonServer/routes/voice.py
PythonServer/routes/voice.py
+9
-4
PythonServer/scripts/api.py
PythonServer/scripts/api.py
+54
-0
No files found.
NodeServer/src/routes/application.ts
View file @
346ad209
...
...
@@ -75,11 +75,13 @@ router.put(
let
update
=
req
.
body
.
update
;
if
(
update
.
interview
?.
videoRef
)
{
VoiceAPI
.
verifyVoice
({
video_url
:
update
.
interview
?.
videoRef
,
user_id
:
req
.
body
.
candidateId
,
application_id
:
req
.
body
.
applicationId
,
});
try
{
VoiceAPI
.
verifyVoice
({
video_url
:
update
.
interview
?.
videoRef
,
user_id
:
req
.
body
.
candidateId
,
application_id
:
req
.
body
.
applicationId
,
});
}
catch
(
error
)
{}
}
Application
.
findByIdAndUpdate
(
req
.
body
.
applicationId
,
{
...
...
@@ -95,6 +97,30 @@ router.put(
}
);
router
.
put
(
"
/update/voice-verification
"
,
async
(
req
:
TypedRequest
<
{},
{
applicationId
:
string
;
update
:
number
;
}
>
,
res
)
=>
{
const
update
=
req
.
body
.
update
.
toString
();
Application
.
findByIdAndUpdate
(
req
.
body
.
applicationId
,
{
$set
:
{
"
interview.voiceVerification
"
:
update
},
})
.
then
((
_application
)
=>
{
res
.
send
(
"
success
"
);
})
.
catch
((
err
)
=>
res
.
send
(
err
));
}
);
router
.
post
(
"
/analyse
"
,
authMiddleware
,
...
...
NodeServer/src/routes/user.ts
View file @
346ad209
...
...
@@ -13,7 +13,7 @@ router.post(
async
(
req
:
TypedRequest
<
{
userId
:
string
},
CandidateType
>
,
res
)
=>
{
try
{
const
update
=
req
.
body
;
await
Candidates
.
findByIdAndUpdate
(
req
.
query
.
userId
,
{
$set
:
update
});
if
(
req
.
body
?.
resume
)
{
const
data
:
any
=
await
ResumeAPI
.
extractResumeData
({
user_id
:
req
.
query
.
userId
,
...
...
@@ -21,11 +21,14 @@ router.post(
});
update
.
resumeData
=
data
;
}
await
Candidates
.
findByIdAndUpdate
(
req
.
query
.
userId
,
{
$set
:
update
});
if
(
req
.
body
?.
selfIntro
)
{
VoiceAPI
.
enrollVoice
({
user_id
:
req
.
query
.
userId
,
video_url
:
req
.
body
.
selfIntro
,
});
try
{
VoiceAPI
.
enrollVoice
({
user_id
:
req
.
query
.
userId
,
video_url
:
req
.
body
.
selfIntro
,
});
}
catch
(
error
)
{}
}
return
res
.
status
(
200
).
json
({
data
:
req
.
body
});
...
...
PythonServer/routes/voice.py
View file @
346ad209
...
...
@@ -10,6 +10,7 @@ from scripts.processing import extract_input_feature
from
keras.models
import
load_model
from
scripts.parameters
import
MODEL_FILE
,
MAX_SEC
from
scripts.voice_feature_extraction
import
get_embedding
from
scripts.api
import
SingletonAiohttp
router
=
APIRouter
(
prefix
=
'/voice'
)
...
...
@@ -33,17 +34,17 @@ def enroll(payload:EnrollVoice):
try
:
os
.
remove
(
video_filename
)
except
:
print
(
'
error
'
)
print
(
''
)
try
:
os
.
remove
(
audio_filename
)
except
:
print
(
'
error
'
)
print
(
''
)
return
'SUCCESS'
@
router
.
post
(
"/verify"
)
def
verify
(
payload
:
VerifyVoice
):
async
def
verify
(
payload
:
VerifyVoice
):
video_filename
=
'videos/interviews/'
+
payload
.
application_id
+
'.mp4'
urllib
.
request
.
urlretrieve
(
payload
.
video_url
,
video_filename
)
...
...
@@ -58,8 +59,12 @@ def verify(payload:VerifyVoice):
test_embs
=
np
.
array
(
test_result
.
tolist
())
enroll_embs
=
np
.
load
(
"voices/auth/embed/"
+
payload
.
user_id
+
".npy"
)
distance
=
euclidean
(
test_embs
,
enroll_embs
)
url
=
"http://localhost:5000/applications/update/voice-verification"
payload
=
{
'update'
:
round
(
1
-
distance
,
5
),
'applicationId'
:
payload
.
application_id
}
return
round
(
1
-
distance
,
5
)
await
SingletonAiohttp
.
put_url
(
url
,
payload
)
return
'success'
@
router
.
post
(
"/analyse"
)
def
analys
(
payload
:
AnalyseVoice
):
...
...
PythonServer/scripts/api.py
0 → 100644
View file @
346ad209
import
aiohttp
from
socket
import
AF_INET
from
typing
import
List
,
Optional
,
Any
,
Dict
SIZE_POOL_AIOHTTP
=
100
class
SingletonAiohttp
:
aiohttp_client
:
Optional
[
aiohttp
.
ClientSession
]
=
None
@
classmethod
def
get_aiohttp_client
(
cls
)
->
aiohttp
.
ClientSession
:
if
cls
.
aiohttp_client
is
None
:
timeout
=
aiohttp
.
ClientTimeout
(
total
=
2
)
connector
=
aiohttp
.
TCPConnector
(
family
=
AF_INET
,
limit_per_host
=
SIZE_POOL_AIOHTTP
)
cls
.
aiohttp_client
=
aiohttp
.
ClientSession
(
timeout
=
timeout
,
connector
=
connector
)
return
cls
.
aiohttp_client
@
classmethod
async
def
close_aiohttp_client
(
cls
)
->
None
:
if
cls
.
aiohttp_client
:
await
cls
.
aiohttp_client
.
close
()
cls
.
aiohttp_client
=
None
@
classmethod
async
def
post_url
(
cls
,
url
:
str
)
->
Any
:
client
=
cls
.
get_aiohttp_client
()
try
:
async
with
client
.
post
(
url
)
as
response
:
if
response
.
status
!=
200
:
return
{
"ERROR OCCURED"
+
str
(
await
response
.
text
())}
json_result
=
await
response
.
json
()
except
Exception
as
e
:
return
{
"ERROR"
:
e
}
return
json_result
@
classmethod
async
def
put_url
(
cls
,
url
:
str
,
payload
)
->
Any
:
client
=
cls
.
get_aiohttp_client
()
try
:
async
with
client
.
put
(
url
,
data
=
payload
)
as
response
:
if
response
.
status
!=
200
:
return
{
"ERROR OCCURED"
+
str
(
await
response
.
text
())}
json_result
=
await
response
.
json
()
except
Exception
as
e
:
return
{
"ERROR"
:
e
}
return
json_result
\ 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