In this third post on my preferred python beginner projects I continue by building a jokes app using python. Yap it tells jokes because it has text to speech conversion.
It fetches the jokes from an API
To get started we will need first have a code editor :
either * pycharm * VScode or * Sublime
- Next step create a file and give a .py extension
- Now you will have to install pyjokes: pip install pyjokes
- Next you will need a text to speech conversion, you will have to install pyttxs3: pip install pyttxs3
- After doing the basics you can now write the code below and run it
import pyjokes
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
rate = engine.getProperty('rate')
engine.setProperty('rate', rate+-20)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def joke():
speak(pyjokes.get_joke())
if __name__ == "__main__":
joke()
Feel free To add your python scripts to my GitHub repo
Also Give me a follow on dev
Top comments (0)