Commit ec100f17 authored by H.M.C. Nadunithara Wijerathne's avatar H.M.C. Nadunithara Wijerathne

Merge branch 'it1924312' into 'master'

video conference

See merge request !9
parents caae35d8 19d12043
......@@ -14,3 +14,5 @@ export const DEFAULT_CONTROLS = {
},
};
export const UTILITY_SERVER = "http://127.0.0.1:8000";
export const API_KEY = '5b9267df-e7bc-4fb8-906d-5bacf5fb62e5';
export const SECRETE_KEY = '72764420a20cdaa4313f21cf8ae6df86a7c25a9b6813e23359c0f58b0a619c7a'
......@@ -53,7 +53,7 @@ router.post(
applicationId: _application.id,
});
} catch (error) {
return res.json({ success: false, error });
return res.status(400).send(error);
}
}
);
......@@ -67,7 +67,7 @@ router.put(
{
applicationId: string;
update: Partial<ApplicationType>;
candidateId: string;
candidateId?: string;
}
>,
res
......@@ -97,6 +97,34 @@ router.put(
}
);
router.put(
"/update/action",
authMiddleware,
async (
req: TypedRequest<
{},
{
applicationId: string;
update: Partial<ApplicationType>;
}
>,
res
) => {
let update = req.body.update;
Application.findByIdAndUpdate(req.body.applicationId, {
$set: update,
})
.then((_application) => {
res.json({
success: true,
application: { ..._application, ...update },
});
})
.catch((err) => res.send(err));
}
);
router.put(
"/update/voice-verification",
async (
......
......@@ -23,7 +23,12 @@ import {
processAttempt,
updatePasswordFromProcessedData,
} from "../utilities/keystroke";
import { DEFAULT_CONTROLS, JWT_SECRET } from "../config/contants";
import {
API_KEY,
DEFAULT_CONTROLS,
JWT_SECRET,
SECRETE_KEY,
} from "../config/contants";
import { authMiddleware } from "../middlewares/auth";
const router = Router();
......@@ -255,4 +260,24 @@ router.post(
}
);
router.get("/conference/key", authMiddleware, async (req, res) => {
try {
const payload = {
apikey: API_KEY,
permissions: [`allow_join`], // `ask_join` || `allow_mod`
version: 2,
roles: ["CRAWLER"],
};
const token = await jwt.sign(payload, SECRETE_KEY, {
expiresIn: "5h",
algorithm: "HS256",
});
return res.json({ token });
} catch (error) {
return res.status(400).send(error);
}
});
module.exports = router;
......@@ -3,7 +3,7 @@ import {
JobType,
TypedRequest,
USER_TYPE,
} from "../config/types";
} from "../config/types";
import {
authMiddleware,
organizationMiddleware,
......@@ -26,7 +26,7 @@ router.get(
jobs = await Jobs.find()
.populate({
path: "applications",
select: ["candidate", "status"],
select: ["candidate", "status", "interview"],
})
.populate({ path: "organization" });
} else {
......@@ -102,4 +102,23 @@ router.delete(
}
);
router.get("/search", authMiddleware, (req:TypedRequest<{key:string}, null>, res)=>{
console.log(req.query.key)
const pipeline = [
{
$search: {
index: "searchJobs",
text: {
query: req.query.key,
path: {"wildcard":"*"},
fuzzy: {},
},
},
}
];
Jobs.aggregate(pipeline).then((data) => res.status(200).json({ data })).catch(()=>{
res.status(200).json({ data:[] })
});
})
module.exports = router;
import nltk
nltk.download('stopwords')
\ No newline at end of file
......@@ -45,26 +45,29 @@ def enroll(payload:EnrollVoice):
@router.post("/verify")
async def verify(payload:VerifyVoice):
video_filename = 'videos/interviews/'+payload.application_id+'.mp4'
urllib.request.urlretrieve(payload.video_url, video_filename)
try:
video_filename = 'videos/interviews/'+payload.application_id+'.mp4'
urllib.request.urlretrieve(payload.video_url, video_filename)
# Download video and save audio
video = moviepy.editor.VideoFileClip(video_filename)
audio = video.audio
audio_filename = 'voices/interviews/'+payload.application_id+'.wav'
audio.write_audiofile(audio_filename, codec='pcm_s16le', bitrate='50k')
# Download video and save audio
video = moviepy.editor.VideoFileClip(video_filename)
audio = video.audio
audio_filename = 'voices/interviews/'+payload.application_id+'.wav'
audio.write_audiofile(audio_filename, codec='pcm_s16le', bitrate='50k')
model = load_model(MODEL_FILE)
test_result = get_embedding(model, audio_filename, MAX_SEC)
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 }
model = load_model(MODEL_FILE)
test_result = get_embedding(model, audio_filename, MAX_SEC)
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 }
await SingletonAiohttp.put_url(url, payload)
await SingletonAiohttp.put_url(url, payload)
return 'success'
return 'success'
except:
return 'failed'
@router.post("/analyse")
def analys(payload:AnalyseVoice):
......
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