Commit f5dfc049 authored by Wanigasinghe N.T. | IT18229912's avatar Wanigasinghe N.T. | IT18229912

Merge branch 'feat/it18229912' into 'develop'

Completed grammer suggestions integration

See merge request !50
parents 87ae7884 75ceaabc
# Default ignored files
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="pytest" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/21_22-j-02.iml" filepath="$PROJECT_DIR$/.idea/21_22-j-02.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
from happytransformer import HappyTextClassification,TTSettings, HappyTextToText
import speech_recognition as sr
import moviepy.editor as mp
def grammerchecker():
def convertText():
clip = mp.VideoFileClip(r"F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\media\\video\\22\\publicspeech.mp4")
clip.audio.write_audiofile(r"converted_mp3.wav")
r = sr.Recognizer()
audio =sr.AudioFile(r"converted_mp3.wav")
with audio as source:
r.pause_threshold = 1
r.adjust_for_ambient_noise(source, duration=1)
audio_file = r.record(source)
stt = r.recognize_google(audio_file)
return stt
def grammerchecker(speechText):
happy_tt = HappyTextClassification(load_path = "F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\users\\models\\grammermodels\\")
beam_settings = TTSettings(num_beams=5, min_length=1, max_length=500)
happy_tt = HappyTextToText("T5", "t5-base")
example_1 = "Sri Lanka's documented history goes back 3,000 years, with evidence of prehistoric human settlements that dates to at least 125,000 years ago.[14] It has a rich cultural heritage. The earliest known Buddhist writings of Sri Lanka, known collectively as the Pāli canon, date to the fourth Buddhist council, which took place in 29 BCE.[15][16] Sri Lanka's geographic location and deep harbours have made it of great strategic importance, from the earliest days of the ancient Silk Road trade route to today's so-called maritime Silk Road"
example_1 = speechText
result_1 = happy_tt.generate_text(example_1, args=beam_settings)
print(result_1.text)
return(result_1.text)
result = grammerchecker()
speechText = convertText()
result = grammerchecker(speechText)
import speech_recognition as sr
import moviepy.editor as mp
clip = mp.VideoFileClip(r"F:\\CDAP-PRESENTLY\\21_22-j-02\\Presently\\presently\\media\\video\\22\\publicspeech.mp4")
clip.audio.write_audiofile(r"converted_mp3.wav")
r = sr.Recognizer()
audio =sr.AudioFile(r"converted_mp3.wav")
with audio as source:
r.pause_threshold = 1
r.adjust_for_ambient_noise(source, duration=1)
audio_file = r.record(source)
result = r.recognize_google(audio_file)
print(result)
\ No newline at end of file
......@@ -11,12 +11,46 @@
</ol>
</nav>
<div class="heading-text heading-section text-center py-3">
<h4>Pronuciation and Grammer Errors</h4>
<h4 class="mb-0">Pronuciation and Grammer Suggestions</h4>
<span class="lead">See what presently think about your presentation</span>
</div>
<hr/>
<div class="tabs my-5">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab"
aria-controls="home" aria-selected="true">Grammer Suggestions</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab"
aria-controls="profile" aria-selected="false">Pronuciation Errors</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel"
aria-labelledby="home-tab">
<h2 class="pb-5">You have said..</h2>
<div class="pb-5 mx-5">
<h4 style="color: grey;">" {{ stt }} "</h4>
</div>
<h4>{{ result }}</h4>
<div class="py-5">
<h2>What <span><img src="{% static 'users/images/title.png' %}" class="img-fluid" style="width: 230px;"></span> Suggest to say...</h2>
</div>
<section class="background-colored">
<div id="particles-dots" class="particles"></div>
<div class="container">
<div class="heading-text text-light px-5">
<h4>{{ result }}</h4>
</div>
</div>
</section>
</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
</div>
</div>
</div>
<div class="d-flex justify-content-center mb-5">
<a class="btn btn-outline" href="{% url 'overallfeedback' %}" type="submit">View summery detail</a>
......
......@@ -46,9 +46,11 @@ def aboutus(request):
return render(request, 'users/aboutus.html')
def pronuciation(request):
stt = grammerchecker.speechText
result = grammerchecker.result
context= {
'result': result,
'stt': stt
}
return render(request, 'users/pronuciation.html',context)
......
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