In this post we will learn about How Create a A.I Jokes using python programming using 8 lines of Python Programming language . In this program we using "pyttsx3 " and "pyjokes" package.
Packages required:
To build a personal voice assistant it’s necessary to install the following packages in your system using the pip command.
1) pyttsx3 — pyttxs3 is a text to speech conversion library in python. This package supports text to speech engines on Mac os x, Windows and on Linux.
How to install pyttsx3:
Note : we need to install pyttsx3 library using pip install in cmd in command prompt
Example : "pip install pyttsx3"
How to install pyjokes:
Note : we need to install pyjokes library using pip install in cmd in command prompt
Example : "pip install pyjokes"
3) Execute the below code in any python compiler
Source code:
import pyjokes, pyttsx3
temp=pyttsx3.init()
joke = pyjokes.get_joke()
print(joke)
temp.say(joke)
temp.runAndWait() (code-box)
Video output: