Commit 325d7379 authored by LiniEisha's avatar LiniEisha

Integrate

parent 676918b1
......@@ -18,16 +18,17 @@ from .ExtractKeySentences import GetLectureNotice
from .Summary import LectureSummary
from .noise import noise_removal
from .speech_to_text import speech_to_text
from .voice_recorder import AudioRecorder
class LectureAudioAPI(APIView):
def get(self, request):
def post(self, request):
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.query_params.get("audio_name")
audio_name = request.data['audio_name']
# id = int(request.query_params.get("id"))
new_audio_id = generate_new_id(audio_list.lecture_audio_noise_removed_id)
......
import json
import requests
# this method calls all the summarization methods in one place
def summarization_batch_process(audio_id, audio_name):
is_all_processed = False
noise_removed_resp = requests.get('http://127.0.0.1:800/summary/lecture-audio-noise-removed', params={'id': audio_id, 'audio_name': audio_name})
if noise_removed_resp.json()['response'] == 200:
audio_root_name = audio_name.split('.')[0]
speech_to_text_name = audio_root_name + '.txt'
audio_text_resp = requests.get('http://127.0.0.1:800/summary/lecture-audio-to-text', params={'id': audio_id, 'speech_to_text_name': speech_to_text_name})
if audio_text_resp.json()['response'] == 200:
summary_name = audio_name + '.txt'
summary_resp = requests.get('http://127.0.0.1:800/summary/lecture-summary', params={'id': audio_id, 'lecture_summary_name': summary_name})
if summary_resp.json()['response'] == 200:
notice_resp = requests.get('http://127.0.0.1:800/summary/lecture-notices', params={'id': audio_id, 'lecture_notice_name': summary_name})
if notice_resp.json()['response'] == 200:
is_all_processed = True
return is_all_processed
def save_lecturer_audio(lecturer_audio):
data_dumps = json.dumps(lecturer_audio)
response = None
headers = {
'Content-Type': 'application/json'
}
# call the API
# student_video_save_resp = requests.post('http://127.0.0.1:8000/lecture-video', student_video)
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]
return response
# this is a test method (delete later)
if __name__ == '__main__':
audio_id = 1
audio_name = 'Lecture01.wav'
summarization_batch_process(audio_id=audio_id, audio_name=audio_name)
\ No newline at end of file
......@@ -12,7 +12,7 @@ urlpatterns = [
# API to retrieve lecture summarizing details
url(r'^lecture-audio/$', api.LectureAudioAPI.as_view()),
url(r'^lecture-audio', api.LectureAudioAPI.as_view()),
url(r'^lecture-audio-noise-removed/$', api.audioNoiseRemovedList.as_view()),
......
......@@ -12,7 +12,7 @@ def AudioRecorder(audio):
DESTINATION_DIR = os.path.join(BASE_DIR, "audioArray\\{}".format(audio))
#for the audio
LECTURE_AUDIO_DIR = os.path.join(BASE_DIR, "lectures\\Lecture_{}".format(audio))
LECTURE_AUDIO_DIR = os.path.join(BASE_DIR, "lectures\\{}".format(audio))
# Sampling frequency
......
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