diff --git a/brython_script.bry b/brython_script.bry index 7f8934e..965b078 100644 --- a/brython_script.bry +++ b/brython_script.bry @@ -5,6 +5,10 @@ from browser import document from browser.html import H2, HR import random + +# importing file for text to speech feature +import text_to_speech.py + # document <= "Hello WWW, from Python!" document["TopBox"] <= H2("Random Text Generator, with Python!", align="center") @@ -34,6 +38,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..b5900c0 --- /dev/null +++ b/text_to_speech.py @@ -0,0 +1,19 @@ +# 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 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 +