Commit db7f6bbb authored by sachith.fernando's avatar sachith.fernando

final integration

parent 3f1a804f
from django.contrib import admin
from .models import Student, Attendance
from .models import Student, Attendance, TrainingData
admin.site.register(Student)
admin.site.register(Attendance)
admin.site.register(TrainingData)
# Register your models here.
from django.http import HttpResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework.parsers import JSONParser
from .models import Student, Subject, Attendance
from .serializers import StudentSerializer, SubjectSerializer, AttendanceSerializer, FileSerializer
from .models import Student, Subject, Attendance, TrainingData
from .serializers import StudentSerializer, SubjectSerializer, AttendanceSerializer, FileSerializer, TrainingSerializer
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
......@@ -11,6 +11,7 @@ from rest_framework.parsers import MultiPartParser, FormParser
from . import record
from . import test as t
from . import lecturerVideo as lv
from rest_framework.views import *
......@@ -176,25 +177,86 @@ class InitiateLecture(APIView):
class stopRecording(APIView):
def get(self, request):
t.isStop = 1
t.firstIteration = 0
# lv.isStop = 1
return Response({
"response": "stopped"
})
def post(self, request):
pass
class getTrainingImages(APIView):
def get(self, request):
data = TrainingData.objects.all()
print(data[0].studentId)
serialized = TrainingSerializer(data).data
print(serialized)
return Response({
"response": "goda"
})
def post(self, request):
pass
class StopLectureVideoRecording(APIView):
def get(self, request):
lv.isStop = 1
return Response({
"response": "stopped"
})
def post(self, request):
pass
# test method (delete later)
class TestAPI(APIView):
def get(self, request):
pass
# t.isStop = 0
# param = request.query_params.get('param')
#
# # t.test()
# t.IPWebcamTest(param)
#
# return Response({
# "response": "started"
# })
def post(self, request):
t.isStop = 0
param = request.query_params.get('param')
# t.test()
t.IPWebcamTest()
t.IPWebcamTest(request.data)
# lv.startLecturerVideo(request.data)
return Response({
"response": "started"
})
def post(self, request):
class LecturerVideoAPI(APIView):
def get(self, request):
pass
# t.isStop = 0
# param = request.query_params.get('param')
#
# # t.test()
# t.IPWebcamTest(param)
#
# return Response({
# "response": "started"
# })
def post(self, request):
lv.isStop = 0
# t.test()
lv.startLecturerVideo(request.data)
return Response({
"response": "started"
})
\ No newline at end of file
......@@ -23,7 +23,7 @@ maskNet = load_model(os.path.join(settings.BASE_DIR,'face_detector/mask_detector
class IPWebCam(object):
def __init__(self):
self.url = "http://192.168.8.100:8080/shot.jpg"
self.url = "http://192.168.8.101:8080/shot.jpg"
def __del__(self):
cv2.destroyAllWindows()
......
# Generated by Django 2.2.11 on 2021-01-10 14:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('AttendanceApp', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='TrainingData',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('studentId', models.CharField(default='', max_length=20)),
('image_1', models.CharField(blank=True, default='', max_length=2000000, null=True)),
('image_2', models.CharField(blank=True, default='', max_length=2000000, null=True)),
('image_3', models.CharField(blank=True, default='', max_length=2000000, null=True)),
('image_4', models.CharField(blank=True, default='', max_length=2000000, null=True)),
('image_5', models.CharField(blank=True, default='', max_length=2000000, null=True)),
],
),
]
......@@ -51,6 +51,18 @@ class Lecture(models.Model):
endTime = models.DateField()
day = models.CharField(max_length=20)
class TrainingData(models.Model):
studentId = models.CharField(max_length=20, default='')
image_1 = models.CharField(max_length=2000000, null=True, blank=True, default='')
image_2 = models.CharField(max_length=2000000, null=True, blank=True, default='')
image_3 = models.CharField(max_length=2000000, null=True, blank=True, default='')
image_4 = models.CharField(max_length=2000000, null=True, blank=True, default='')
image_5 = models.CharField(max_length=2000000, null=True, blank=True, default='')
def __str__(self):
return self.studentId
from django.db import models
# Create your models here.
from rest_framework import serializers
from FirstApp.serializers import SubjectSerializer
from .models import Student, Subject, Attendance, File
from .models import Student, Subject, Attendance, File, TrainingData
class StudentSerializer(serializers.ModelSerializer):
......@@ -9,6 +9,12 @@ class StudentSerializer(serializers.ModelSerializer):
model = Student
fields = '__all__'
class TrainingSerializer(serializers.ModelSerializer):
class Meta:
model = TrainingData
fields = '__all__'
#
# class SubjectSerializer(serializers.ModelSerializer):
# class Meta:
......
......@@ -32,6 +32,8 @@
<script>
function toggleLectureLive() {
var x = document.getElementById("liveStreamLecture");
var y = document.getElementById("liveStreamLectureStartButton");
......@@ -48,9 +50,64 @@ var timer = false;
function testAPI() {
timer = true
startTimer()
let param = 'sachith';
let subject_code = "{{ upcomingLecture.subject_code }}";
let subject_name = "{{ upcomingLecture.subject_name }}";
let subject_id = "{{ upcomingLecture.subject_id }}";
let lecturerId = {{ lecturerId }};
let lecturerName = "{{ lecturerName }}";
let year = new Date().getFullYear();
let month = new Date().getMonth();
let date = new Date().getDate();
month = ("0" + (month + 1)).slice(-2);
date = ("0" + date).slice(-2);
let dateFormat = year + "-" + month + "-" + date;
let param = {
'subject_code': subject_code? subject_code: null,
'subject_name': subject_name? subject_name: null,
'lecturerId': lecturerId? Number.parseInt(lecturerId): null,
'lecturerName': lecturerName? lecturerName: null,
'dateFormat': dateFormat? dateFormat: null,
'subject_id': Number.parseInt(subject_id)
};
let paramObj = JSON.stringify(param);
{#let param = 'sachith'#}
//call the API
fetch('http://127.0.0.1:8000/attendance/test-api/?param=' + param)
{#fetch('http://127.0.0.1:8000/attendance/test-api/?param=' + param)#}
{#.then((res) => res.json())#}
{#.then((out) => {})#}
{#.catch((err) => alert('error: ' + err));#}
fetch('http://127.0.0.1:8000/attendance/test-api', {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: paramObj
})
.then((res) => res.json())
.then((out) => {})
.catch((err) => alert('error: ' + err));
}
function saveLectureRecording(obj) {
fetch('http://127.0.0.1:8000/attendance/lecture-video-api', {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: obj
})
.then((res) => res.json())
.then((out) => {})
.catch((err) => alert('error: ' + err));
......@@ -63,15 +120,56 @@ function testAPI() {
.catch((err) => alert('error: ' + err));
}
var time = 'time';
function train() {
fetch('http://127.0.0.1:8000/attendance/training-api/').then((value) => value.json()).then((data) => alert(data.response)).catch((err) => alert(error))
}
function f() {
let param = 'sachith';
let year = new Date().getFullYear();
let month = new Date().getMonth();
let date = new Date().getDate();
if (month < 9) {
month = "0" + month + 1;
}
else {
month = month + 1;
}
let dateFormat = year + "-" + month + "-" + date;
{#let param = {#}
{# 'subject_code': subject_code? subject_code: null,#}
{# 'subject_name': subject_name? subject_name: null,#}
{# 'lecturerId': lecturerId? lecturerId: null,#}
{# 'lecturerName': lecturerName? lecturerName: null,#}
{# 'dateFormat': dateFormat? dateFormat: null#}
{#};#}
let param = 'sachith'
//call the API
fetch('http://127.0.0.1:8000/attendance/stop-api/?param=' + param)
.then((res) => res.json())
.then((out) => {
timer = false
startTimer();
{#timer = false#}
{#stopLectureVideoRecording();#}
})
.catch((err) => alert('error: ' + err));
}
function stopLectureVideoRecording() {
fetch('http://127.0.0.1:8000/attendance/stop-lecture-api/')
.then((res) => res.json())
.then((out) => {
alert(out)
})
.catch((err) => alert('error: ' + err));
}
......@@ -106,7 +204,7 @@ function startTimer() {
<div class="text-center">
<div class="card">
<div class="card-header">
<h4 class="card-title">Lecture Live</h4>
<h4 class="card-title">{{ upcomingLecture.subject_code }} {{ upcomingLecture.subject_name }} Live</h4>
</div>
<div class="card-body">
......@@ -126,6 +224,9 @@ function startTimer() {
<div class="col">
<button style="display: block; width: 70px; height: 70px;" id="liveStreamLectureStartButton" class="btn btn-warning btn-circle" onclick="f()"><i class="fas fa-square"></i></button>
</div>
<div class="col">
<button style="display: block; width: 70px; height: 70px;" id="train" class="btn btn-warning btn-circle" onclick="train()"><i class="fas fa-plus"></i></button>
</div>
</div>
</div>
</div>
......
import json
import requests
import urllib3
import urllib.request as req
import cv2
import numpy as np
import time
import os
import time
from threading import *
import face_recognition
isStop = 0
from AttendanceApp.models import Student, Attendance
from FirstApp.MongoModels import Subject
from FirstApp.logic.id_generator import generate_new_id
def IPWebcamTest():
isStop = 0
firstIteration = 0
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(BASE_DIR)
def videoDir(name):
VIDEO_DIR = os.path.join(BASE_DIR, "static\\FirstApp\\videos\\{}".format(name))
return VIDEO_DIR
def imageDir(name):
IMAGE_DIR = os.path.join(BASE_DIR, "AttendanceApp\\unknown\\{}".format(name))
return IMAGE_DIR
def saveImage(img, name, subjectCode, date, subjectId, lecturerId):
cv2.imwrite(imageDir(name + '.png'), img)
knownEncodings = []
knownNames = []
actualKnownNames = []
knownDir = os.path.join(BASE_DIR, "AttendanceApp\\known")
unknownDir = os.path.join(BASE_DIR, "AttendanceApp\\unknown")
knownDir = knownDir.replace('\\', '/')
unknownDir = unknownDir.replace('\\', '/')
for file in os.listdir(knownDir):
image = resizeImage(knownDir + '/' + file)
img_encodings = face_recognition.face_encodings(image)[0]
knownEncodings.append(img_encodings)
knownNames.append(file.split('.')[0])
attendance = []
for file in os.listdir(unknownDir):
print('processing ' + file)
image = resizeImage(unknownDir + '/' + file)
img_encodings = face_recognition.face_encodings(image)
print(face_recognition.face_encodings(image))
if not len(img_encodings):
print('cannot find encodeings for ' + file)
continue
img_encodings = face_recognition.face_encodings(image)[0]
results = face_recognition.compare_faces(knownEncodings, img_encodings)
print(results)
for i in range(len(results)):
if results[i]:
attendance.append(knownNames[i].split('(')[0])
print(list(set(attendance)))
saveAttendanceToDB(list(set(attendance)), subjectCode, date)
def startProcessing(lecturerId, subejectId, subjectCode):
content = {
'lecturer': lecturerId,
'subject': subejectId,
'subject_code': subjectCode,
'video_length': '00:20:00'
}
json_content = json.dumps(content)
headers = {
'Content-Type': 'application/json'
}
response = requests.post('http://127.0.0.1:8000/automation-process/', data=json_content, headers=headers)
return response
def saveAttendanceToDB(students, subjectCode, date):
subject = Subject.objects.filter(subject_code=subjectCode)
allStudents = Student.objects.all()
for aS in allStudents:
for s in students:
if s == aS.studentId:
prev_attendance = Attendance.objects.order_by('attendanceID').last()
newAttendanceId = "SA00001" if prev_attendance is None else generate_new_id(
prev_attendance.attendanceID)
Attendance(
attendanceID=newAttendanceId,
student=aS,
subject=subject[0],
date=date,
attendance=True,
feedback=''
).save()
else:
prev_attendance = Attendance.objects.order_by('attendanceID').last()
newAttendanceId = "SA00001" if prev_attendance is None else generate_new_id(
prev_attendance.attendanceID)
Attendance(
attendanceID=newAttendanceId,
student=aS,
subject=subject[0],
date=date,
attendance=False,
feedback=''
).save()
def resizeImage(img):
img = cv2.imread(img)
(h, w) = img.shape[:2]
width = 600
ratio = width / float(w)
height = int(h * ratio)
return cv2.resize(img, (width ,height))
def startThread(img, name, subject, date, subjectId, lecturerId):
t = Thread(saveImage(img, name, subject, date, subjectId, lecturerId))
time.sleep(2)
t.start()
def IPWebcamTest(params):
# Replace the URL with your own IPwebcam shot.jpg IP:port
# url = 'http://192.168.2.35:8080/shot.jpg'
url = 'http://192.168.8.100:8080/shot.jpg'
# url = 'http://192.168.137.209:8080/shot.jpg'
url = 'http://192.168.8.101:8080/shot.jpg'
# url = 'http://192.168.1.11:8080/startvideo?force=1&tag=rec'
# url = 'http://192.168.1.11:8080/stopvideo?force=1'
size = (600, 600)
vid_cod = cv2.VideoWriter_fourcc(*'XVID')
video_name = params['dateFormat'] + "_" + params['subject_code'] + "_student_video.mp4"
attendanceCaptureName = params['dateFormat'] + "_" + params['subject_code'] + "_student_video"
subject_id = params['subject_id']
lecturer_id = params['lecturerId']
subject_code = params['subject_code']
print('video name: ', video_name)
vid_cod = cv2.VideoWriter_fourcc(*'mp4v')
# vid_cod = cv2.VideoWriter_fourcc('M', 'J', 'P', 'G')
# output = cv2.VideoWriter("cam_video.avi", vid_cod, 20.0, (640, 480))
# output = cv2.VideoWriter("cam_video.mp4", vid_cod, 20.0, size)
output = cv2.VideoWriter("cam_video.mp4", vid_cod, 10.0, size)
output = cv2.VideoWriter(videoDir(video_name), vid_cod, 10.0, size)
no_of_frames = 0
firstIteration = 0
while True:
# Use urllib to get the image from the IP camera
......@@ -36,6 +169,9 @@ def IPWebcamTest():
# Finally decode the array to OpenCV usable format ;)
img = cv2.imdecode(imgNp, -1)
if firstIteration == 0:
startThread(img, attendanceCaptureName + '(1)', params['subject_code'], params['dateFormat'], subject_id, lecturer_id)
firstIteration = 1
# resize the image
img = cv2.resize(img, (600, 600))
......@@ -51,8 +187,13 @@ def IPWebcamTest():
no_of_frames += 1
if isStop == 1:
print('stopping')
break
# after saving the video, save the changes to static content
p = os.popen("python manage.py collectstatic", "w")
p.write("yes")
startProcessing(lecturer_id, subject_id, subject_code)
# imgResp.release()
# cv2.destroyAllWindows()
print('no of frames: ', no_of_frames)
\ No newline at end of file
......@@ -22,7 +22,12 @@ urlpatterns = [
url(r'^process-initiate-lecture/$', InitiateLecture.as_view()),
# this url will be used for testing
url(r'^test-api/$', TestAPI.as_view()),
url(r'^stop-api/$', stopRecording.as_view())
url(r'^test-api', TestAPI.as_view()),
url(r'^stop-api/$', stopRecording.as_view()),
url(r'^training-api/$', getTrainingImages.as_view()),
# this url will be used for testing
url(r'^lecture-video-api', LecturerVideoAPI.as_view()),
url(r'^stop-lecture-api/$', stopRecording.as_view())
]
from django.shortcuts import render
from django.http.response import StreamingHttpResponse
from AttendanceApp.camera import IPWebCam
from FirstApp.MongoModels import LectureVideo
from FirstApp.serializers import LectureVideoSerializer
from FirstApp.MongoModels import LectureVideo, FacultyTimetable
from FirstApp.serializers import LectureVideoSerializer, FacultyTimetableSerializer
import datetime as d
from datetime import datetime
def initiate_lecture(request):
lecture_video = LectureVideo.objects.all()
lecture_video_ser = LectureVideoSerializer(lecture_video, many=True)
def initiate_lecture(request):
lecturer = request.session['lecturer']
lecturerName = request.session['lecturer-name']
print('lecture video data: ', lecture_video_ser.data)
print(lecturer)
upcoming_lecture_details = upcoming_lecture_request(lecturer)
print(upcoming_lecture_details)
return render(request, "AttendanceApp/Initiate_lecture.html")
context = {'lecturerId': lecturer, 'lecturerName': lecturerName, 'upcomingLecture': upcoming_lecture_details}
return render(request, "AttendanceApp/Initiate_lecture.html", context)
def gen(camera):
......@@ -25,3 +30,141 @@ def gen(camera):
def webcam_feed(request):
return StreamingHttpResponse(gen(IPWebCam()),
content_type='multipart/x-mixed-replace; boundary=frame')
def upcoming_lecture_request(lecturer):
cur_date = d.datetime.now().date()
cur_time = d.datetime.now().time()
print('lecturer: ', lecturer)
upcoming_lecture_details = {}
# retrieve the faculty timetable
faculty_timetable = FacultyTimetable.objects.all()
# serialize the timetable
faculty_timetable_serialized = FacultyTimetableSerializer(faculty_timetable, many=True)
# get the serialized timetable data
faculty_timetable_serialized_data = faculty_timetable_serialized.data
# iterate through the serialized timetable data
for timetable in faculty_timetable_serialized_data:
# get the 'timetable' field
daily_timetable = timetable['timetable']
# iterate through the 'timetable' field
for day_timetable in daily_timetable:
# get the 'time_slots' field for a given day
time_slots = day_timetable['time_slots']
# iterate through the time slots
for time_slot in time_slots:
# if the lecturer is the currently logged in lecturer
if lecturer == time_slot['lecturer']['id']:
# find the upcoming lecture for the logged-in lecturer
if cur_date == day_timetable['date']:
# get the start and end times
start_time = time_slot['start_time']
end_time = time_slot['end_time']
start_time_list = str(start_time).split(":")
start_time_date = d.datetime.now().replace(hour=int(start_time_list[0]),
minute=int(start_time_list[1]),
second=int(start_time_list[2]))
end_time_list = str(end_time).split(":")
end_time_date = d.datetime.now().replace(hour=int(end_time_list[0]),
minute=int(end_time_list[1]),
second=int(end_time_list[2]))
# check for the upcoming time slot
if (start_time_date.time() > cur_time):
upcoming_lecture_details['eligible_start_time'] = start_time_date.time()
upcoming_lecture_details['eligible_end_time'] = end_time_date.time()
upcoming_lecture_details['subject_id'] = time_slot['subject']['id']
upcoming_lecture_details['subject_name'] = time_slot['subject']['name']
upcoming_lecture_details['subject_code'] = time_slot['subject']['subject_code']
return upcoming_lecture_details
# lecturer = int(lecturer)
# lecturer = int(lecturer)
# cur_date = datetime.datetime.now().date()
# cur_date = d.datetime.now().date()
# cur_time = d.datetime.now().time()
#
# # upcoming lecture details
# upcoming_lecture_details = {}
#
# eligible_start_time = ''
# eligible_end_time = ''
# subject_id = 0
# subject_name = ''
# subject_code = ''
#
# # retrieve the faculty timetable
# faculty_timetable = FacultyTimetable.objects.all()
#
# # serialize the timetable
# faculty_timetable_serialized = FacultyTimetableSerializer(faculty_timetable, many=True)
#
# # get the serialized timetable data
# faculty_timetable_serialized_data = faculty_timetable_serialized.data
#
# # iterate through the serialized timetable data
# for timetable in faculty_timetable_serialized_data:
#
# # get the 'timetable' field
# daily_timetable = timetable['timetable']
#
# # iterate through the 'timetable' field
# for day_timetable in daily_timetable:
#
# # get the 'time_slots' field for a given day
# time_slots = day_timetable['time_slots']
#
# # iterate through the time slots
# for time_slot in time_slots:
#
# # if the lecturer is the currently logged in lecturer
# if lecturer == time_slot['lecturer']['id']:
#
# # find the upcoming lecture for the logged-in lecturer
# if cur_date == day_timetable['date']:
#
# # get the start and end times
# start_time = time_slot['start_time']
# end_time = time_slot['end_time']
#
# start_time_list = str(start_time).split(":")
#
# start_time_date = d.datetime.now().replace(hour=int(start_time_list[0]),
# minute=int(start_time_list[1]),
# second=int(start_time_list[2]))
#
# end_time_list = str(end_time).split(":")
#
# end_time_date = d.datetime.now().replace(hour=int(end_time_list[0]),
# minute=int(end_time_list[1]),
# second=int(end_time_list[2]))
#
# # check for the upcoming t ime slot
# if (start_time_date.time() > cur_time):
# upcoming_lecture_details['eligible_start_time'] = start_time_date.time()
# upcoming_lecture_details['eligible_end_time'] = end_time_date.time()
# upcoming_lecture_details['subject_id'] = time_slot['subject']['id']
# upcoming_lecture_details['subject_name'] = time_slot['subject']['name']
# upcoming_lecture_details['subject_code'] = time_slot['subject']['subject_code']
#
# return upcoming_lecture_details
......@@ -119,13 +119,13 @@ def automation_process(lecturer, subject, subject_code, video_length="00:20:00")
# start the batch processing for lecture summarization component
lecture_summary_batch_process = summarization_batch_process(audio_id, lecturer_audio_name)
lecture_summary_batch_process, summary_id = summarization_batch_process(audio_id, lecturer_audio_name)
# if the lecture summarization process is successful
if lecture_summary_batch_process:
# start the batch processing for monitoring lecturer performance component
lecturer_batch_process_response = lecturer_batch_process(lecturer_video_name, lecturer_audio_name)
lecturer_batch_process_response = lecturer_batch_process(lecturer_video_name, lecturer_audio_name, summary_id)
# if the lecturer performance process is successful
if lecturer_batch_process_response:
......
......@@ -353,6 +353,7 @@ def loggedInView(request):
login(request, user)
# setting up the session
request.session['lecturer'] = lecturer.id
request.session['lecturer-name'] = lecturer.fname + ' ' + lecturer.lname
request.session['user_type'] = "Lecturer"
return redirect('/')
......
import nltk
nltk.download('punkt')
import os
from fpdf import FPDF
......
......@@ -29,27 +29,35 @@ class LectureAudioAPI(APIView):
})
def post(self, request):
print('main target')
lecture_audio = LectureAudio.objects.all().order_by('lecturer_date')
lecture_audio_serializer = LectureAudioSerializer(lecture_audio, many=True)
audio_list = LectureAudio.objects.order_by('lecture_audio_id').last()
audio_name = request.data['audio_name']
print(lecture_audio)
print(audio_list)
print(audio_name)
# id = int(request.query_params.get("id"))
new_audio_id = generate_new_id(audio_list.lecture_audio_noise_removed_id)
new_audio_id = generate_new_id(audio_list.lecture_audio_id)
print(new_audio_id)
fake_duration = datetime.timedelta(minutes=00, seconds=10, milliseconds=00)
AudioRecorder(audio_name)
# AudioRecorder(audio_name)
LectureAudio(
lecture_audio_id=new_audio_id,
lecture_audio_name =audio_name,
lecture_audio_length = fake_duration,
lecturer =request.data["lecturer"],
subject = request.data["subject"]
lecturer_id =int(request.data["lecturer"]),
subject_id = int(request.data["subject"]),
lecturer_date=datetime.datetime.now().date()
).save()
# get the created lecture audio instance
created_lecture_audio = LectureAudio.objects.filter(lecture_audio_id=new_audio_id)
print(created_lecture_audio)
return Response({
"response": Response.status_code,
......@@ -167,7 +175,9 @@ class LectureSummaryList(APIView):
audio_original_text=text,
audio_summary=summary
).save()
return Response({"response": Response.status_code})
# created_summary = LectureS
return Response({"response": Response.status_code, "summary_id": lecture_summary_id})
def post(self, request):
LectureAudioSummary(
......
......@@ -7,7 +7,7 @@ def summarization_batch_process(audio_id, audio_name):
is_all_processed = False
summary_id = ''
noise_removed_resp = requests.get('http://127.0.0.1:8000/summary/lecture-noise/', params={'id': audio_id, 'audio_name': audio_name})
......@@ -27,12 +27,14 @@ def summarization_batch_process(audio_id, audio_name):
print('successful audio to text response')
summary_name = audio_name + '.txt'
summary_name = audio_name.split('.')[0] + '.txt'
summary_resp = requests.get('http://127.0.0.1:8000/summary/lecture-summary/', params={'id': audio_id, 'lecture_summary_name': summary_name})
if summary_resp.json()['response'] == 200:
summary_id = summary_resp.json()['summary_id']
print('successful summary response')
notice_resp = requests.get('http://127.0.0.1:8000/summary/lecture-notices/', params={'id': audio_id, 'lecture_notice_name': summary_name})
......@@ -42,7 +44,7 @@ def summarization_batch_process(audio_id, audio_name):
is_all_processed = True
return is_all_processed
return is_all_processed, summary_id
......@@ -60,7 +62,7 @@ def save_lecturer_audio(lecturer_audio):
lecturer_audio_save_resp = requests.post(url='http://127.0.0.1:8000/summary/lecture-audio', data=data_dumps, headers=headers)
data = lecturer_audio_save_resp.json()
response = data[0]
response = data
return response
......
perhaps this is what is PR agency is are their dignity schedule III was much is 50 feet then the choreographer missed arbitrated never go back into acquiescence with things as they work finds it in misery and isolation around us in this instance such personal purchase for a luxury leather cases of severe and advisement say he is a horse days Ranjan or he may have a point that contains between fuel prices straight line which symbolises uniqueness the circuit universality of small hole in wall with client has more subtle implications in passport expiry marketing program manufacturers taking initiative of the costs involved cricket overlapping twisted widely spaced to you always navigate like this
\ No newline at end of file
......@@ -10,10 +10,10 @@ def speech_to_text(speech_to_text_name):
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# FILE_PATH = os.path.join(BASE_DIR, "noise_removed_lectures\\noise_removed_lectures_{}".format(speech_to_text_name))
FILE_PATH = os.path.join(BASE_DIR, "lectures\\{}".format(speech_to_text_name))
FILE_PATH = os.path.join(BASE_DIR, "lectures\\{}".format(speech_to_text_name.split('.')[0]+'.wav'))
print('file path: ', FILE_PATH)
# DESTINATION_DIR = os.path.dirname(os.path.join(BASE_DIR, "LectureSummarizingApp\\speechToText\\{}.txt".format(speech_to_text_name)))
DESTINATION_DIR = os.path.join(BASE_DIR, "speechToText\\{}.txt".format(speech_to_text_name))
DESTINATION_DIR = os.path.join(BASE_DIR, "speechToText\\{}".format(speech_to_text_name))
print('destination directory: ', DESTINATION_DIR)
with sr.AudioFile(FILE_PATH) as source:
......
......@@ -225,6 +225,7 @@ class ProcessLectureAudioAnalysis(APIView):
def get(self, request):
# lec_audio_text = ta.run()
summary_id = request.query_params.get('summary_id')
# (this is temporary)
lec_audio_text = {
......@@ -238,7 +239,7 @@ class ProcessLectureAudioAnalysis(APIView):
last_lec_audio_text_id.lecturer_audio_text_id)
# retrieve the lecture audio summary object (temporary)
lecture_audio_summary = LectureAudioSummary.objects.filter(lecture_audio_summary_id='LAU004_sum')[0]
lecture_audio_summary = LectureAudioSummary.objects.filter(lecture_audio_summary_id=summary_id)[0]
# save the lecture audio text object
LecturerAudioText(
......
......@@ -2,26 +2,26 @@ import requests
import json
# this method lists down the main methods that need to be executed when the lecturer performance module is under operation
def lecturer_batch_process(video_name, audio_name):
def lecturer_batch_process(video_name, audio_name, summary_id):
is_all_processed = False
# As the first step, calculate the lectuer activity details
# lecturer_activity_resp = requests.get('http://127.0.0.1:8000/activities/?video_name=' + video_name)
lecturer_activity_resp = requests.get('http://127.0.0.1:8000/activities/', params={'video_name': video_name})
lecturer_activity_resp = requests.get('http://127.0.0.1:8000/lecturer/activities/', params={'video_name': video_name})
# if the lecturer activity is created
if lecturer_activity_resp.json()['created']:
# save the lecturer video frame recognitions
# lecturer_video_frame_recognitions_resp = requests.get('http://127.0.0.1:8000/process-lecturer-video-frame-recognitions/?video_name=' + video_name)
lecturer_video_frame_recognitions_resp = requests.get('http://127.0.0.1:8000/process-lecturer-video-frame-recognitions/', params={'video_name': video_name})
lecturer_video_frame_recognitions_resp = requests.get('http://127.0.0.1:8000/lecturer/process-lecturer-video-frame-recognitions/', params={'video_name': video_name})
# if the lecture video frame recognitions are created
if lecturer_video_frame_recognitions_resp.json()['created']:
# processing the lecture audio
lecture_audio_text_resp = requests.get('http://127.0.0.1:8000/lecturer/process-lecture-audio-analysis')
lecture_audio_text_resp = requests.get('http://127.0.0.1:8000/lecturer/process-lecture-audio-analysis/', params={'summary_id': summary_id})
# if the lecturer audio text is processed
if lecture_audio_text_resp.json()['created']:
......
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