In this post we will learn about How to How to create a AI voice assistant using 8 lines of Python Programming language . In this program we using "pyttsx3 " and "wikipedia" 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"
2) wikipedia — Many members of the academic community, including freshmen, students, and professors, use the multilingual online encyclopaedia Wikipedia to learn more about a particular subject. This Python package pulls the necessary data from Wikipedia.
Note : we need to install wikipedia library using pip install in cmd in command prompt
Example : "pip install wikipedia "
3) Execute the below code in any python compiler
Source code:
import pyttsx3
import wikipedia
#let us assume our voice assistance name will be "mithran"
mithran = pyttsx3.init()
In= input("search wikipedia/Google:")
result = wikipedia.summary(In, sentences = 2)
print(result)
mithran.say(result)
mithran.runAndWait() (code-box)
Video output: