Skip to content
Related Articles

Related Articles

Improve Article

Voice Assistant for Movies using Python

  • Last Updated : 28 Sep, 2021

In this article, we will see how a voice assistant can be made for searching for movies or films. After giving input as movie name in audio format and it will give the information about that movie in audio format as well.

As we know the greatest searching website for movies is IMDb. IMDb is an online database of information related to films, television programs, home videos, video games, and streaming content online including cast, production crew, and personal biographies, plot summaries, trivia, ratings, and fan, and critical reviews.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course


  • IMDbPY: It is a Python package useful to retrieve and manage the data of the IMDb movie database about movies, people, characters, and companies. It can be installed using the below command:
pip install IMDbPY
  • pyttsx3: It is a text-to-speech conversion library in Python. Unlike alternative libraries, it works offline and is compatible with both Python 2 and 3. It can be installed using the below command:
pip install pyttsx3
  • SpeechRecognition: Library for performing speech recognition, with support for several engines and APIs, online and offline. It can be installed using the below command:
pip install SpeechRecognition
  • Datetime: Encapsulation of date/time values. It can be installed using the below command:
pip install DateTime


  • Import required modules.
  • Create the below functions:
    • speak( ): This function will help our assistant to speak up.
    • get_audio( ): This function will help the assistant to get the input by the user.
    • get_movies( ): This function will help the assistant to search for the movie that is given as input.
  • Create a new function search_movie( ) to search a movie by using the above function calls.
  • Call the above-created function.

Below is the Implementation.


# importing all required libraries
import imdb
import pyttsx3
import speech_recognition as sr
import datetime
# Function for speaking
def speak(text):
    engine = pyttsx3.init()
    voices = engine.getProperty('voices')
    engine.setProperty('voice', voices[1].id)
    rate = engine.getProperty('rate')
    engine.setProperty('rate', rate-20)
# calling the speak() function
speak("Say the movie name")
# Function to get input in the audio format
def get_audio():
    r = sr.Recognizer()
    with sr.Microphone() as source:
        r.pause_threshold = 1
        r.adjust_for_ambient_noise(source, duration=1)
        audio = r.listen(source)
        said = ""
        # will recognize the input
        said = r.recognize_google(audio)
        speak("Didn't get that")
    # will return the input in lowercase
    return said.lower()
# Function for searching movie
def search_movie():
    # gathering information from IMDb
    moviesdb = imdb.IMDb()
    # search for title
    text = get_audio()
    # passing input for searching movie
    movies = moviesdb.search_movie(text)
    speak("Searching for " + text)
    if len(movies) == 0:
        speak("No result found")
        speak("I found these:")
        for movie in movies:
            title = movie['title']
            year = movie['year']
            # speaking title with releasing year
            info = movie.getID()
            movie = moviesdb.get_movie(info)
            title = movie['title']
            year = movie['year']
            rating = movie['rating']
            plot = movie['plot outline']
            # the below if-else is for past and future release
            if year < int("%Y")):
                    f'{title}was released in {year} has IMDB rating of {rating}.\
                    The plot summary of movie is{plot}')
                    f'{title}was released in {year} has IMDB rating of {rating}.\
                    The plot summary of movie is{plot}')
                    f'{title}will release in {year} has IMDB rating of {rating}.\
                    The plot summary of movie is{plot}')
                    f'{title}will release in {year} has IMDB rating of {rating}.\
                    The plot summary of movie is{plot}')

The above code will speak the information about the film as the user gave the input and also print about it.



Parasitewas released in 2019 has IMDB rating of 8.6.

The plot summary of movie isThe Kims – mother and father Chung-sook and Ki-taek, and their young adult offspring, son Ki-woo and daughter Ki-jung – are a poor family living in a shabby and cramped half basement apartment in a busy lower working class commercial district of Seoul. 

Without even knowing it, they, especially Mr. and Mrs. Kim, literally smell of poverty. Often as a collective, they perpetrate minor scams to get by, and even when they have jobs, they do the minimum work required. Ki-woo is the one who has dreams of getting out of poverty by one day going to university. 

Despite not having that university education, Ki-woo is chosen by his university student friend Min, who is leaving to go to school, to take over his tutoring job to Park Da-hye, who Min plans to date once he returns to Seoul and she herself is in university.

The Parks are a wealthy family who for four years have lived in their modernistic house designed by and the former residence of famed architect Namgoong. While Mr. and Mrs. Park are all about status, Mrs. Park has a flighty, simpleminded mentality and temperament,

which Min tells Ki-woo to feel comfortable in lying to her about his education to get the job. In getting the job, Ki-woo further learns that Mrs. Park is looking for an art therapist for the Parks’ adolescent son, Da-song, Ki-woo quickly recommending his professional art therapist friend “Jessica”, 

really Ki-jung who he knows can pull off the scam in being the easiest liar of the four Kims. In Ki-woo also falling for Da-hye, he begins to envision himself in that house, and thus the Kims as a collective start a plan for all the Kims, like Ki-jung using assumed names, to replace existing servants in the Parks’ employ in orchestrating reasons for them to be fired.

The most difficult to get rid of may be Moon-gwang, the Parks’ housekeeper who literally came with the house – she Namgoong’s housekeeper when he lived there – and thus knows all the little nooks and crannies of it better than the Parks themselves. The question then becomes how far the Kims can take this scam in their quest to become their version of the Parks.

My Personal Notes arrow_drop_up
Recommended Articles
Page :