'Find the corresponding value in an excel sheet corresponding to a voice input

I have a program that takes voice input from user and saves it as text in 'query'

import speech_recognition as sr
import pyaudio
import os
import pandas as pd

def takeCommand():
     
    r = sr.Recognizer()
     
    with sr.Microphone() as source:
         
        print("Listening...")
        r.pause_threshold = 1
        audio = r.listen(source)
  
    try:
        print("Recognizing...")   
        query = r.recognize_google(audio, language ='en-in')
        print(f"User said: {query}\n")
  
    except Exception as e:
        print(e)   
        print("Unable to Recognize your voice.") 
        return "None"
     
    return query
query = takeCommand().lower()

With this code if the user says elephant it gets saved in query I also have a excel file like this: https://ln5.sync.com/dl/74c24e6c0/jstexh6s-ahcwxerd-mfi22h79-54tnp4a3 What i want is as the user said 'elephant' i want the corresponding definition to be displayed. How can i do this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source