Commit 32398952 authored by P.S.D.Perera's avatar P.S.D.Perera

init

parent 95296850
# Default ignored files
/shelf/
/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="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</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/2021-156.iml" filepath="$PROJECT_DIR$/.idea/2021-156.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" />
<mapping directory="$PROJECT_DIR$/Voice/watson-streaming-stt" vcs="Git" />
</component>
</project>
\ No newline at end of file
# Default ignored files
/shelf/
/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="jdk" jdkName="Python 3.8 (voice)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</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 (voice)" 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/Voice.iml" filepath="$PROJECT_DIR$/.idea/Voice.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$/watson-streaming-stt" vcs="Git" />
</component>
</project>
\ No newline at end of file
import speech_recognition as sr
import pyttsx3
import TextComparison
reading_test = "I don't like to play cricket"
result = 0
r = sr.Recognizer()
engine = pyttsx3.init()
rate = engine.getProperty('rate')
engine.setProperty('rate', rate - 10)
with sr.Microphone() as source:
print("Hi, please read the text and wait for me to listen")
engine.say('Hi, please read the text and wait for me to listen')
print('\n' + reading_test)
engine.runAndWait()
audio = r.listen(source)
print('listening...')
try:
text = r.recognize_google(audio)
print("You said : {}".format(text))
comparison = TextComparison.Comparison(reading_test.lower(), str(text).lower())
result = comparison.get_difference()
except:
print("Sorry could not recognize what you said")
engine.say('Sorry could not recognize what you said')
engine.runAndWait()
print('Accuracy is ' + str(result) + '%')
engine.say('Accuracy is ' + str(result) + '%')
engine.runAndWait()
import difflib
class Comparison:
def __init__(self, first_text, second_text):
self.first_text = first_text
self.second_text = second_text
def get_difference(self):
sequence = difflib.SequenceMatcher(isjunk=None, a=self.first_text, b=self.second_text)
difference = sequence.ratio() * 100
difference = round(difference, 1)
return difference
import nltk
# nltk.download('punkt')
from nltk.tokenize import sent_tokenize
from nltk.tokenize import word_tokenize
import gensim
import numpy as np
document = []
document2 = []
reading_test = 'Philosophy of Education is a label applied to the study of the purpose, process, nature and ideals of education. It can be considered a branch of both philosophy and education. Education can be defined as the teaching and learning of specific skills, and the imparting of knowledge, judgment and wisdom, and is something broader than the societal institution of education we often speak of.'
reading_test2 = 'Philosophy of Education is a label applied to the study of the purpose, process, nature and ideals of education. It can be considered a branch of both philosophy and education. Education can be defined as the teaching and learning of specific skills, and the imparting of knowledge, judgment and wisdom, and is something broader than the societal institution of education we often speak of.'
sentences = sent_tokenize(reading_test)
for sentence in sentences:
document.append(sentence)
sentences2 = sent_tokenize(reading_test2)
for sentence2 in sentences2:
document2.append(sentence2)
#
# for d in document:
# print(d)
gen_docs = [[w.lower() for w in word_tokenize(text)] for text in document]
gen_docs2 = [[w.lower() for w in word_tokenize(text)] for text in document2]
dictionary = gensim.corpora.Dictionary(gen_docs)
dictionary2 = dictionary.doc2bow(gen_docs2)
corpus = [dictionary.doc2bow(gen_doc) for gen_doc in gen_docs]
tf_idf = gensim.models.TfidfModel(corpus)
sims = gensim.similarities.Similarity('Documents/', tf_idf[corpus], num_features=len(dictionary))
# query_doc_tf_idf = tf_idf(q)
pip install SpeechRecognition
pip install pyttsx3
pip install nltk
pip install gensim
pip install numpy
Subproject commit 8b59d55d591690867728c4659b75b15535067b86
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