video conference

parent caae35d8
...@@ -14,3 +14,5 @@ export const DEFAULT_CONTROLS = { ...@@ -14,3 +14,5 @@ export const DEFAULT_CONTROLS = {
}, },
}; };
export const UTILITY_SERVER = "http://127.0.0.1:8000"; 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( ...@@ -53,7 +53,7 @@ router.post(
applicationId: _application.id, applicationId: _application.id,
}); });
} catch (error) { } catch (error) {
return res.json({ success: false, error }); return res.status(400).send(error);
} }
} }
); );
...@@ -67,7 +67,7 @@ router.put( ...@@ -67,7 +67,7 @@ router.put(
{ {
applicationId: string; applicationId: string;
update: Partial<ApplicationType>; update: Partial<ApplicationType>;
candidateId: string; candidateId?: string;
} }
>, >,
res res
...@@ -97,6 +97,34 @@ router.put( ...@@ -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( router.put(
"/update/voice-verification", "/update/voice-verification",
async ( async (
......
...@@ -23,7 +23,12 @@ import { ...@@ -23,7 +23,12 @@ import {
processAttempt, processAttempt,
updatePasswordFromProcessedData, updatePasswordFromProcessedData,
} from "../utilities/keystroke"; } 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"; import { authMiddleware } from "../middlewares/auth";
const router = Router(); const router = Router();
...@@ -255,4 +260,24 @@ router.post( ...@@ -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; module.exports = router;
...@@ -3,7 +3,7 @@ import { ...@@ -3,7 +3,7 @@ import {
JobType, JobType,
TypedRequest, TypedRequest,
USER_TYPE, USER_TYPE,
} from "../config/types"; } from "../config/types";
import { import {
authMiddleware, authMiddleware,
organizationMiddleware, organizationMiddleware,
...@@ -26,7 +26,7 @@ router.get( ...@@ -26,7 +26,7 @@ router.get(
jobs = await Jobs.find() jobs = await Jobs.find()
.populate({ .populate({
path: "applications", path: "applications",
select: ["candidate", "status"], select: ["candidate", "status", "interview"],
}) })
.populate({ path: "organization" }); .populate({ path: "organization" });
} else { } else {
...@@ -102,4 +102,23 @@ router.delete( ...@@ -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; module.exports = router;
import nltk
nltk.download('stopwords')
\ No newline at end of file
...@@ -45,26 +45,29 @@ def enroll(payload:EnrollVoice): ...@@ -45,26 +45,29 @@ def enroll(payload:EnrollVoice):
@router.post("/verify") @router.post("/verify")
async def verify(payload:VerifyVoice): async def verify(payload:VerifyVoice):
video_filename = 'videos/interviews/'+payload.application_id+'.mp4' try:
urllib.request.urlretrieve(payload.video_url, video_filename) video_filename = 'videos/interviews/'+payload.application_id+'.mp4'
urllib.request.urlretrieve(payload.video_url, video_filename)
# Download video and save audio # Download video and save audio
video = moviepy.editor.VideoFileClip(video_filename) video = moviepy.editor.VideoFileClip(video_filename)
audio = video.audio audio = video.audio
audio_filename = 'voices/interviews/'+payload.application_id+'.wav' audio_filename = 'voices/interviews/'+payload.application_id+'.wav'
audio.write_audiofile(audio_filename, codec='pcm_s16le', bitrate='50k') audio.write_audiofile(audio_filename, codec='pcm_s16le', bitrate='50k')
model = load_model(MODEL_FILE) model = load_model(MODEL_FILE)
test_result = get_embedding(model, audio_filename, MAX_SEC) test_result = get_embedding(model, audio_filename, MAX_SEC)
test_embs = np.array(test_result.tolist()) test_embs = np.array(test_result.tolist())
enroll_embs = np.load("voices/auth/embed/"+ payload.user_id+".npy") enroll_embs = np.load("voices/auth/embed/"+ payload.user_id+".npy")
distance = euclidean(test_embs, enroll_embs) distance = euclidean(test_embs, enroll_embs)
url = "http://localhost:5000/applications/update/voice-verification" url = "http://localhost:5000/applications/update/voice-verification"
payload = {'update':round(1-distance, 5), 'applicationId':payload.application_id } 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") @router.post("/analyse")
def analys(payload:AnalyseVoice): 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