From 857219c607e6d977e5f0f899d4ac4bbee5fb83db Mon Sep 17 00:00:00 2001 From: Nish251103 Date: Sat, 3 Oct 2020 11:45:03 +0530 Subject: [PATCH 1/4] This python program would read the text for the user which is randomly generated --- brython_script.bry | 20 ++++++++++++++++++++ text_to_speech.py | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 text_to_speech.py diff --git a/brython_script.bry b/brython_script.bry index 7f8934e..324d218 100644 --- a/brython_script.bry +++ b/brython_script.bry @@ -5,6 +5,23 @@ from browser import document from browser.html import H2, HR import random +# importing stuff for speech +import pyttsx3 +import speech_recognition as sr +from difflib import SequenceMatcher + +# defining voice and engine + +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +engine.setProperty('voice', voices[1].id) # index 0 is for female voice and 1 is for male voice + +# defining module for speaking + +def speak(audio): + engine.say(audio) + break + # document <= "Hello WWW, from Python!" document["TopBox"] <= H2("Random Text Generator, with Python!", align="center") @@ -34,6 +51,9 @@ for paragraph_iteration in range(number_of_paragraphs): Output_String += ("\n\n") # Output_String += ("

") +speak(Output_String) # the user can hear the text generated now + + # print(Output_String) # print() logs the data to console and does not write it on page. # document <= Output_String # This writes directly to the document diff --git a/text_to_speech.py b/text_to_speech.py new file mode 100644 index 0000000..3b5b2a5 --- /dev/null +++ b/text_to_speech.py @@ -0,0 +1,20 @@ +# this file is for the referance and the code has been intigrated into the main file(brython_script.bry) + +# importing stuff for speech +import pyttsx3 +import mport speech_recognition as sr +from difflib import SequenceMatcher + +# defining voice and engine + +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +engine.setProperty('voice', voices[1].id) # index 0 is for female voice and 1 is for male voice + +# defining module for speaking + +def speak(audio): + engine.say(audio) + break + +speak('it will speak the text generated') From 304220468743723a3cad7edba1fc56e843c9319f Mon Sep 17 00:00:00 2001 From: Nishchal <71500515+Nish251103@users.noreply.github.com> Date: Sat, 3 Oct 2020 12:25:26 +0530 Subject: [PATCH 2/4] Update text_to_speech.py --- text_to_speech.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text_to_speech.py b/text_to_speech.py index 3b5b2a5..763ea27 100644 --- a/text_to_speech.py +++ b/text_to_speech.py @@ -2,7 +2,7 @@ # importing stuff for speech import pyttsx3 -import mport speech_recognition as sr +import speech_recognition as sr from difflib import SequenceMatcher # defining voice and engine From 3b919dea62ea7e1fe79efb9d53e234bff975a3d1 Mon Sep 17 00:00:00 2001 From: Nishchal <71500515+Nish251103@users.noreply.github.com> Date: Sat, 3 Oct 2020 12:28:28 +0530 Subject: [PATCH 3/4] Update text_to_speech.py --- text_to_speech.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/text_to_speech.py b/text_to_speech.py index 763ea27..b5900c0 100644 --- a/text_to_speech.py +++ b/text_to_speech.py @@ -16,5 +16,4 @@ def speak(audio): engine.say(audio) break - -speak('it will speak the text generated') + From 082ed9f632bd697fd1223f4ebe6aa8f8de6d9157 Mon Sep 17 00:00:00 2001 From: Nishchal <71500515+Nish251103@users.noreply.github.com> Date: Sat, 3 Oct 2020 12:29:48 +0530 Subject: [PATCH 4/4] Update brython_script.bry --- brython_script.bry | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/brython_script.bry b/brython_script.bry index 324d218..965b078 100644 --- a/brython_script.bry +++ b/brython_script.bry @@ -5,22 +5,9 @@ from browser import document from browser.html import H2, HR import random -# importing stuff for speech -import pyttsx3 -import speech_recognition as sr -from difflib import SequenceMatcher -# defining voice and engine - -engine = pyttsx3.init('sapi5') -voices = engine.getProperty('voices') -engine.setProperty('voice', voices[1].id) # index 0 is for female voice and 1 is for male voice - -# defining module for speaking - -def speak(audio): - engine.say(audio) - break +# importing file for text to speech feature +import text_to_speech.py # document <= "Hello WWW, from Python!"