Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speaking the generated text #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions brython_script.bry
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -34,6 +51,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
20 changes: 20 additions & 0 deletions text_to_speech.py
Original file line number Diff line number Diff line change
@@ -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')