Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions brython_script.bry
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -34,6 +38,9 @@ for paragraph_iteration in range(number_of_paragraphs):
Output_String += ("\n\n")
# Output_String += ("<br><br>")

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
Expand Down
19 changes: 19 additions & 0 deletions text_to_speech.py
Original file line number Diff line number Diff line change
@@ -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