Commit d4597493 authored by I.K Seneviratne's avatar I.K Seneviratne

Merge branch 'IT17100908' into 'QA_RELEASE'

It17100908

See merge request !19
parents a2d180df 746d3825
import spacy
from spacy.lang.pt.stop_words import STOP_WORDS
from sklearn.feature_extraction.text import CountVectorizer
import pt_core_news_sm
# Reading the file
nlp = pt_core_news_sm.load()
with open("audioToText01.txt", "r", encoding="utf-8") as f:
text = " ".join(f.readlines())
doc = nlp(text)
#calculating the word frequency
corpus = [sent.text.lower() for sent in doc.sents ]
cv = CountVectorizer(stop_words=list(STOP_WORDS))
cv_fit=cv.fit_transform(corpus)
......@@ -18,6 +18,7 @@ word_list = cv.get_feature_names()
count_list = cv_fit.toarray().sum(axis=0)
word_frequency = dict(zip(word_list,count_list))
val=sorted(word_frequency.values())
higher_word_frequencies = [word for word,freq in word_frequency.items() if freq in val[-3:]]
print("\nWords with higher frequencies: ", higher_word_frequencies)
......@@ -26,6 +27,7 @@ higher_frequency = val[-1]
for word in word_frequency.keys():
word_frequency[word] = (word_frequency[word]/higher_frequency)
#calculating sentence rank and taking top ranked sentences for the summary
sentence_rank={}
for sent in doc.sents:
for word in sent :
......
What is OOP OBJECT ORIENTED PROGRAMMING is a programming concept that works on the principles of abstraction, encapsulation, inheritance, and polymorphism. The basic concept of OOPs is to create objects, re-use them throughout the program, and manipulate these objects to get results. Object Oriented Programming popularly known as OOP, is used in a modern programming language like Java OBJECT ORIENTED PROGRAMMING is a programming concept that works on the principles of abstraction, encapsulation, inheritance and polymorphism the basic concept of OOPs is to create objects re-use them in the program and manipulate these objects to get results Object Oriented Programming popularly known as OOP, is used in programming language like Java. Core OOPS concepts are as follow. While the methods may be performed with these cars are driving, reverse, braking etc. next is Object An object can be defined as an instance of a class, and there can be multiple instances of a class in a program.
\ No newline at end of file
......@@ -9,7 +9,7 @@ from LectureSummarizingApp.serializer import LectureAudioSerializer, LectureAudi
from . import speech_to_text as stt
# this API will retrieve lecture audio details
# APIs used in Lecture Summarizing Component
class LectureAudioAPI(APIView):
def get(self, request):
......
# from django.db import models
from djongo import models
# Create your models here.
# Models used in Lecture Summarization Component
from FirstApp.MongoModels import Lecturer, Subject
......
......@@ -4,6 +4,7 @@ from FirstApp.serializers import LecturerSerializer, SubjectSerializer
from . models import *
#serializers used in Lecture Summarizing Component
class LectureAudioSerializer(serializers.ModelSerializer):
lecturer = LecturerSerializer()
......@@ -23,7 +24,6 @@ class LectureAudioNoiseRemovedSerializer(serializers.ModelSerializer):
class LectureSpeechToTextSerializer(serializers.ModelSerializer):
# lecture_speech_to_text_id = LectureAudioNoiseRemovedSerializer()
lecture_audio_id = LectureAudioSerializer()
class Meta:
......@@ -32,7 +32,6 @@ class LectureSpeechToTextSerializer(serializers.ModelSerializer):
class LectureAudioSummarySerializer(serializers.ModelSerializer):
# lecture_audio_noise_removed_id = LectureSpeechToTextSerializer()
lecture_audio_id = LectureAudioSerializer()
class Meta:
......@@ -41,10 +40,8 @@ class LectureAudioSummarySerializer(serializers.ModelSerializer):
class LectureNoticesSerializer(serializers.ModelSerializer):
# lecture_audio_noise_removed_id = LectureSpeechToTextSerializer()
lecture_audio_id = LectureAudioSerializer()
class Meta:
# model = LectureAudioSummary
model = LectureNotices
fields = '__all__'
\ No newline at end of file
......@@ -4,17 +4,17 @@ import os
def speech_to_text(video_name):
#calling the Recognizer()
r = sr.Recognizer()
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
VIDEO_PATH = os.path.join(BASE_DIR, "lectures\\{}".format(video_name))
with sr.AudioFile(VIDEO_PATH) as source:
audio = r.listen(source)
file = open('audioToText01.txt', 'w')
file = open('audioToText01.txt', 'w') #open file
try:
text = r.recognize_google(audio)
text = r.recognize_google(audio) #Convert using google recognizer
file.write(text)
except:
file.write('error')
......
......@@ -5,27 +5,12 @@ from django.conf.urls import url
from . import api
router = routers.DefaultRouter()
# router.register(r'^register', views.register)
urlpatterns = [
path('lecture', views.summarization),
# path('', views.hello),
# path('login', views.login),
# path('register', views.register),
# path('404', views.view404),
# path('blank', views.blank),
# path('buttons', views.buttons),
# path('cards', views.cards),
# path('charts', views.charts),
# path('forgot-password', views.forget_password),
# # path('webcam', views.webcam),
# path('template', views.template),
# path('base', views.base),
# path('child', views.child),
# path('lecture-video', views.lecVideo),
# # path('Video', views.hello)
# API to retrieve activity recognition
# API to retrieve lecture summarizing details
url(r'^lecture-audio/$', api.LectureAudioAPI.as_view()),
url(r'^lecture-audio-noise-removed/$', api.audioNoiseRemovedList.as_view()),
......@@ -36,15 +21,6 @@ urlpatterns = [
url(r'^lecture-notices/$', api.lectureNoticeList.as_view()),
# # API to retrieve audio analysis
# url(r'^get-audio-analysis', api.GetLectureAudioAnalysis.as_view()),
#
# # API to retrieve lecture audio text
# url(r'^get-lecture-audio-text', api.LectureAudioTextAPI.as_view()),
#
# # test API
# url(r'^test-api', api.TestAPI.as_view()),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
]
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from rest_framework.views import APIView
from rest_framework.response import Response
......@@ -9,7 +7,7 @@ from .serializer import LectureAudioSerializer, LectureAudioNoiseRemovedSerializ
LectureSpeechToTextSerializer, LectureNoticesSerializer
# Create your views here.
# Views used in Lecture Summarization
def summarization(request):
......
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