Commit bd82963e authored by LiniEisha's avatar LiniEisha

Demo (for pp2) changes

parent 9adf5bf2
...@@ -14,7 +14,7 @@ doc = nlp(text) ...@@ -14,7 +14,7 @@ doc = nlp(text)
corpus = [sent.text.lower() for sent in doc.sents ] corpus = [sent.text.lower() for sent in doc.sents ]
cv = CountVectorizer(stop_words=list(STOP_WORDS)) cv = CountVectorizer(stop_words=list(STOP_WORDS))
cv_fit=cv.fit_transform(corpus) cv_fit=cv.fit_transform(corpus)
word_list = cv.get_feature_names(); word_list = cv.get_feature_names()
count_list = cv_fit.toarray().sum(axis=0) count_list = cv_fit.toarray().sum(axis=0)
word_frequency = dict(zip(word_list,count_list)) word_frequency = dict(zip(word_list,count_list))
...@@ -37,6 +37,8 @@ for sent in doc.sents: ...@@ -37,6 +37,8 @@ for sent in doc.sents:
top_sentences=(sorted(sentence_rank.values())[::-1]) top_sentences=(sorted(sentence_rank.values())[::-1])
top_sent=top_sentences[:3] top_sent=top_sentences[:3]
summary=[] summary=[]
for sent,strength in sentence_rank.items(): for sent,strength in sentence_rank.items():
if strength in top_sent: if strength in top_sent:
...@@ -44,4 +46,6 @@ for sent,strength in sentence_rank.items(): ...@@ -44,4 +46,6 @@ for sent,strength in sentence_rank.items():
else: else:
continue continue
for i in summary: for i in summary:
print(i,end=" ") file = open('Summary01.txt', 'w')
\ No newline at end of file file.write(str(i))
file.close()
\ No newline at end of file
...@@ -6,6 +6,8 @@ from LectureSummarizingApp.models import LectureAudio, LectureAudioNoiseRemoved, ...@@ -6,6 +6,8 @@ from LectureSummarizingApp.models import LectureAudio, LectureAudioNoiseRemoved,
from LectureSummarizingApp.serializer import LectureAudioSerializer, LectureAudioNoiseRemovedSerializer, \ from LectureSummarizingApp.serializer import LectureAudioSerializer, LectureAudioNoiseRemovedSerializer, \
LectureSpeechToTextSerializer, LectureAudioSummarySerializer, LectureNoticesSerializer LectureSpeechToTextSerializer, LectureAudioSummarySerializer, LectureNoticesSerializer
from . import speech_to_text as stt
# this API will retrieve lecture audio details # this API will retrieve lecture audio details
class LectureAudioAPI(APIView): class LectureAudioAPI(APIView):
...@@ -39,9 +41,26 @@ class audioToTextList(APIView): ...@@ -39,9 +41,26 @@ class audioToTextList(APIView):
def get(self, request): def get(self, request):
lecture_speech_to_text_id = LectureSpeechToText.objects.all() lecture_speech_to_text_id = LectureSpeechToText.objects.all()
serializer = LectureSpeechToTextSerializer(lecture_speech_to_text_id, many=True) serializer = LectureSpeechToTextSerializer(lecture_speech_to_text_id, many=True)
return Response(serializer.data) # return Response(serializer.data)
video_name = request.query_params.get("video_name")
print('video name: ', video_name)
stt.speech_to_text(video_name)
return Response({
"response": "successful"
})
def post(self, request): def post(self, request):
# video_name = request.data["video_name"]
#
# print('video name: ', video_name)
#
# stt.speech_to_text(video_name)
LectureSpeechToText( LectureSpeechToText(
lecture_speech_to_text_id=request.data["lecture_speech_to_text_id"], lecture_speech_to_text_id=request.data["lecture_speech_to_text_id"],
lecture_audio_id=request.data["lecture_audio_id"], lecture_audio_id=request.data["lecture_audio_id"],
...@@ -58,6 +77,9 @@ class lectureSummaryList(APIView): ...@@ -58,6 +77,9 @@ class lectureSummaryList(APIView):
return Response(serializer.data) return Response(serializer.data)
def post(self, request): def post(self, request):
LectureAudioSummary( LectureAudioSummary(
lecture_speech_to_text_id=request.data["lecture_speech_to_text_id"], lecture_speech_to_text_id=request.data["lecture_speech_to_text_id"],
lecture_audio_id=request.data["lecture_audio_id"], lecture_audio_id=request.data["lecture_audio_id"],
......
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 today our lecture is based an introduction to Object Oriented Programming Concepts before going to that lets focus on a few things specific to java In java there are 8 primitive types of data they are byte short int long char float double and boolean from these long int short and byte are integer data types Double and float are float data type unlike languages like C plus plus the sizes of integers floats are fixed and are platform neutral characters this group includes char which represents symbols in a character set like letters and numbers boolean this group includes boolean which is a special type for representing true or false values declaring Objects in Java is a two step process. First, you must declare a variable of the class type this variable does not define an object instead it is simply a variable that can refer to an object second you must use the new operator to dynamically allocates that is, allocates at run time memory for an object and returns a reference to it this reference is more or less the address in memory of the object allocated by new another main thing you need to know is static modifiers they indicates that the attributes and methods are common to all the object in the whole class rather than to an individual object a static method does not operate on an object following are the most commonly used attributes and methods ystem dot out System dot in Math.PI Integer dot parse Int Character dot is Letter There will be times when you will want to define a class member that will be used independently of any object of that class when a member is declared static it can be accessed before any objects of its class are created, and without reference to any object You can declare both methods and variables to be static The most common example of a static member is main is declared as static because it must be called before any objects exist instance variables declared as static are essentially global variables When objects of its class are declared no copy of a static variable is made instead all instances of the class share the same static variable methods declared as static have several restrictions they can only directly call other static methods they can only directly access static data they cannot refer to this or super in any way next important thing is overloading and overriding We will talk about these two separately in another lecture so just for now know that overriding occurs in inheritance when a descendant class replaces a method with the same signature and overloading occurs when there are methods with different signatures now lets move on to our topic object oriented programming what is object oriented programming object oriented programming is a programming concept that works on the principles the main principles are abstraction encapsulation inheritance and polymorphism oop allows users to create the objects that they want and then, create methods to handle those objects the basic concept of oops is to create objects reuse 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 students your 1st assignment will be in next week based on core oop concepts now lets what are core oop concepts first one is class the class is a group of similar entities it is only an logical component which means it is not a physical entity now lets go for example if you had a class called expensive cars the object could be like mercedes bmw toyota etc and the properties an be price or speed of these cars while the methods may be performed with these cars are driving reverse braking next core concept 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 an Object contains both the data and the function which operates on the data For example chair bike marker pen table next we have Inheritance what is inheritance inheritance is an oop concept in which one object acquires the properties and behaviours of the parent object
\ No newline at end of file \ No newline at end of file
import speech_recognition as sr
r = sr.Recognizer()
with sr.AudioFile('female.wav') as source:
audio = r.listen(source)
file = open('audioToText01.txt', 'w')
try:
text = r.recognize_google(audio)
file.write(text)
except:
file.write('error')
file.close()
\ No newline at end of file
import speech_recognition as sr
import os
def speech_to_text(video_name):
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')
try:
text = r.recognize_google(audio)
file.write(text)
except:
file.write('error')
file.close()
\ No newline at end of file
...@@ -29,9 +29,57 @@ ...@@ -29,9 +29,57 @@
<!-- Load Posenet --> <!-- Load Posenet -->
<script src="https://unpkg.com/@tensorflow-models/posenet"> <script src="https://unpkg.com/@tensorflow-models/posenet">
</script> </script>
{% endblock %}
<script type="text/javascript">
$(document).ready(function() {
<!-- speech to text-->
$('.audio_to_text_process').click(function() {
alert('Processing');
//call the fetch API
fetch('http://127.0.0.1:8000/summary/lecture-audio-to-text/?video_name=Lecture01.wav')
.then((res) => res.json())
.then((out) => alert(out.response))
.catch((err) => alert('error: ' + err))
});
<!-- background noise-->
$('.audio_process').click(function() {
alert('Processing');
//call the fetch API
fetch('http://127.0.0.1:8000/summary/lecture-audio-to-text/?video_name=Lecture01.wav')
.then((res) => res.json())
.then((out) => alert(out.response))
.catch((err) => alert('error: ' + err))
});
<!-- To summary-->
$('.to_summary').click(function() {
alert('Processing');
//call the fetch API
fetch('http://127.0.0.1:8000/summary/lecture-audio-to-text/?video_name=Lecture01.wav')
.then((res) => res.json())
.then((out) => alert(out.response))
.catch((err) => alert('error: ' + err))
});
});
</script>
{% endblock %}
<div id="wrapper"> <div id="wrapper">
<div id="content-wrapper" class="d-flex flex-column"> <div id="content-wrapper" class="d-flex flex-column">
<div id="content"> <div id="content">
...@@ -64,7 +112,6 @@ ...@@ -64,7 +112,6 @@
<table class="table table-bordered" id="datatable"> <table class="table table-bordered" id="datatable">
<thead> <thead>
<tr> <tr>
<th></th>
<th>Module</th> <th>Module</th>
<th>Date</th> <th>Date</th>
<th>Recording Name</th> <th>Recording Name</th>
...@@ -75,15 +122,15 @@ ...@@ -75,15 +122,15 @@
{% for lec_audio in lec_audio_data %} {% for lec_audio in lec_audio_data %}
<tr class="recordings not_clicked" id="{{ lec_audio.lecture_audio_id }}"> <tr class="recordings not_clicked" id="{{ lec_audio.lecture_audio_id }}">
<td> <!-- <td>-->
<div class="radio"> <!-- <div class="radio">-->
<label><input type="radio" <!-- <label><input type="radio"-->
id="{{ lec_audio.lecture_audio_id }}" <!-- id="{{ lec_audio.lecture_audio_id }}"-->
name="recording_radio" <!-- name="recording_radio"-->
data-name="{{ lec_audio.lecture_audio_name }}" <!-- data-name="{{ lec_audio.lecture_audio_name }}"-->
></label> <!-- ></label>-->
</div> <!-- </div>-->
</td> <!-- </td>-->
<td>{{ lec_audio.subject.name }}</td> <td>{{ lec_audio.subject.name }}</td>
<td>{{ lec_audio.lecturer_date }}</td> <td>{{ lec_audio.lecturer_date }}</td>
<td>{{ lec_audio.lecture_audio_name }}</td> <td>{{ lec_audio.lecture_audio_name }}</td>
...@@ -125,7 +172,7 @@ ...@@ -125,7 +172,7 @@
<table class="table table-bordered" id="datatable"> <table class="table table-bordered" id="datatable">
<thead> <thead>
<tr> <tr>
<th></th> <!-- <th></th>-->
<th>Module</th> <th>Module</th>
<th>Date</th> <th>Date</th>
<th>Recording Name</th> <th>Recording Name</th>
...@@ -136,20 +183,21 @@ ...@@ -136,20 +183,21 @@
{% for noiseless_audio in noiseless_data %} {% for noiseless_audio in noiseless_data %}
<tr class="recordings not_clicked" id="{{ noiseless_audio.lecture_audio_id }}"> <tr class="recordings not_clicked" id="{{ noiseless_audio.lecture_audio_id }}">
<td> <!-- <td>-->
<div class="radio"> <!-- <div class="radio">-->
<label><input type="radio" <!-- <label><input type="radio"-->
id="{{ noiseless_audio.lecture_audio_id }}" <!-- id="{{ noiseless_audio.lecture_audio_id }}"-->
name="recording_radio" <!-- name="recording_radio"-->
data-name="{{ noiseless_audio.lecture_audio_name }}" <!-- data-name="{{ noiseless_audio.lecture_audio_name }}"-->
></label> <!-- ></label>-->
</div> <!-- </div>-->
</td> <!-- </td>-->
<td>{{ noiseless_audio.lecture_audio_id.subject.name }}</td> <td>{{ noiseless_audio.lecture_audio_id.subject.name }}</td>
<td>{{ noiseless_audio.lecture_audio_id.lecturer_date }}</td> <td>{{ noiseless_audio.lecture_audio_id.lecturer_date }}</td>
<td>{{ noiseless_audio.lecture_audio_name }}</td> <td>{{ noiseless_audio.lecture_audio_name }}</td>
<td> <td>
<button TYPE="button" class="btn btn-success audio_to_text_process">Convert <button type="button"
class="btn btn-success audio_to_text_process">Convert
</button> </button>
</td> </td>
</tr> </tr>
...@@ -192,7 +240,6 @@ ...@@ -192,7 +240,6 @@
<table class="table table-bordered" id="datatable"> <table class="table table-bordered" id="datatable">
<thead> <thead>
<tr> <tr>
<th></th>
<th>Module</th> <th>Module</th>
<th>Date</th> <th>Date</th>
<th>Text ID</th> <th>Text ID</th>
...@@ -204,15 +251,15 @@ ...@@ -204,15 +251,15 @@
{% for lec_text in lecture_text_data %} {% for lec_text in lecture_text_data %}
<tr class="recordings not_clicked" id="{{ lec_text.lecture_audio_id }}"> <tr class="recordings not_clicked" id="{{ lec_text.lecture_audio_id }}">
<td> <!-- <td>-->
<div class="radio"> <!-- <div class="radio">-->
<label><input type="radio" <!-- <label><input type="radio"-->
id="{{ lec_text.lecture_audio_id }}" <!-- id="{{ lec_text.lecture_audio_id }}"-->
name="recording_radio" <!-- name="recording_radio"-->
data-name="{{ lec_text.lecture_audio_name }}" <!-- data-name="{{ lec_text.lecture_audio_name }}"-->
></label> <!-- ></label>-->
</div> <!-- </div>-->
</td> <!-- </td>-->
<td>{{ lec_text.lecture_audio_id.subject.name }}</td> <td>{{ lec_text.lecture_audio_id.subject.name }}</td>
<td>{{ lec_text.lecture_audio_id.lecturer_date }}</td> <td>{{ lec_text.lecture_audio_id.lecturer_date }}</td>
<td>{{ lec_text.lecture_speech_to_text_id }}</td> <td>{{ lec_text.lecture_speech_to_text_id }}</td>
...@@ -221,7 +268,7 @@ ...@@ -221,7 +268,7 @@
</button> </button>
</td> </td>
<td> <td>
<button TYPE="button" class="btn btn-success get_notices">Notices <button TYPE="button" class="btn btn-danger get_notices">Notices
</button> </button>
</td> </td>
</tr> </tr>
...@@ -263,7 +310,6 @@ ...@@ -263,7 +310,6 @@
<table class="table table-bordered" id="datatable"> <table class="table table-bordered" id="datatable">
<thead> <thead>
<tr> <tr>
<th></th>
<th>Module</th> <th>Module</th>
<th>Date</th> <th>Date</th>
<th>Summary</th> <th>Summary</th>
...@@ -273,15 +319,15 @@ ...@@ -273,15 +319,15 @@
{% for lec_summary in lec_summary_data %} {% for lec_summary in lec_summary_data %}
<tr class="recordings not_clicked" id="{{ lec_summary.lecture_audio_id }}"> <tr class="recordings not_clicked" id="{{ lec_summary.lecture_audio_id }}">
<td> <!-- <td>-->
<div class="radio"> <!-- <div class="radio">-->
<label><input type="radio" <!-- <label><input type="radio"-->
id="{{ lec_summary.lecture_audio_id }}" <!-- id="{{ lec_summary.lecture_audio_id }}"-->
name="recording_radio" <!-- name="recording_radio"-->
data-name="{{ lec_summary.lecture_audio_name }}" <!-- data-name="{{ lec_summary.lecture_audio_name }}"-->
></label> <!-- ></label>-->
</div> <!-- </div>-->
</td> <!-- </td>-->
<td>{{ lec_summary.lecture_audio_id.subject.name }}</td> <td>{{ lec_summary.lecture_audio_id.subject.name }}</td>
<td>{{ lec_summary.lecture_audio_id.lecturer_date }}</td> <td>{{ lec_summary.lecture_audio_id.lecturer_date }}</td>
<td>{{ lec_summary.lecture_audio_summary_id }}</td> <td>{{ lec_summary.lecture_audio_summary_id }}</td>
...@@ -317,7 +363,6 @@ ...@@ -317,7 +363,6 @@
<table class="table table-bordered" id="datatable"> <table class="table table-bordered" id="datatable">
<thead> <thead>
<tr> <tr>
<th></th>
<th>Module</th> <th>Module</th>
<th>Date</th> <th>Date</th>
<th>Notices</th> <th>Notices</th>
...@@ -327,15 +372,15 @@ ...@@ -327,15 +372,15 @@
{% for lec_notice in lec_notice_data %} {% for lec_notice in lec_notice_data %}
<tr class="recordings not_clicked" id="{{ lec_notice.lecture_audio_id }}"> <tr class="recordings not_clicked" id="{{ lec_notice.lecture_audio_id }}">
<td> <!-- <td>-->
<div class="radio"> <!-- <div class="radio">-->
<label><input type="radio" <!-- <label><input type="radio"-->
id="{{ lec_notice.lecture_audio_id }}" <!-- id="{{ lec_notice.lecture_audio_id }}"-->
name="recording_radio" <!-- name="recording_radio"-->
data-name="{{ noiseless_audio.lecture_audio_name }}" <!-- data-name="{{ noiseless_audio.lecture_audio_name }}"-->
></label> <!-- ></label>-->
</div> <!-- </div>-->
</td> <!-- </td>-->
<td>{{ lec_notice.lecture_audio_id.subject.name }}</td> <td>{{ lec_notice.lecture_audio_id.subject.name }}</td>
<td>{{ lec_notice.lecture_audio_id.lecturer_date }}</td> <td>{{ lec_notice.lecture_audio_id.lecturer_date }}</td>
<td>{{ lec_notice.lecture_notice_id }}</td> <td>{{ lec_notice.lecture_notice_id }}</td>
......
...@@ -30,7 +30,7 @@ urlpatterns = [ ...@@ -30,7 +30,7 @@ urlpatterns = [
url(r'^lecture-audio-noise-removed/$', api.audioNoiseRemovedList.as_view()), url(r'^lecture-audio-noise-removed/$', api.audioNoiseRemovedList.as_view()),
url(r'^lecture-audio-to-text/$', api.audioToTextList.as_view()), url(r'^lecture-audio-to-text/', api.audioToTextList.as_view()),
url(r'^lecture-summary/$', api.lectureSummaryList.as_view()), url(r'^lecture-summary/$', api.lectureSummaryList.as_view()),
......
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