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

Create Robo Speaker.py #7025

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions Add Code Here/PYTHON/Robo Speaker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pyttsx3

def robo_speaker():
# Initialize the pyttsx3 engine
engine = pyttsx3.init()

# Set properties like rate (speed) and volume if desired
rate = engine.getProperty('rate')
engine.setProperty('rate', rate - 25) # Reduce the rate for clearer speech

volume = engine.getProperty('volume')
engine.setProperty('volume', volume + 0.25) # Increase volume slightly

# Infinite loop to take user input and speak it
while True:
# Get user input
text = input("Enter what you want me to say (or 'exit' to quit): ")

# Break the loop if the user wants to exit
if text.lower() == 'exit':
print("Exiting Robo Speaker. Goodbye!")
break

# Use the TTS engine to say the text
engine.say(text)
engine.runAndWait()

if __name__ == "__main__":
robo_speaker()