Coders Packet

Virtual Assistant answers questions from WolframAlpha and Wikipedia in Python

By Syeed Chowdhury Jahin

  • querybotnora.py
  • Nora is a virtual assistant built by speech recognition system which uses the wolfram API to fetch answers to questions , if answers not found ,it searches Wikipedia for the same.

    Microphone stores users voice in source and after variable with listen function captures voice stored in source through microphone and stores in in a variable audio. In the preceding try catch block what ever the user is said is displayed and exception is caught jusr in case the user said nothing at all.

    query=query.replace('Nora','') is used to remove word name Nora whle sending information to wolframalpha as it will not recognize the name nora.
    client=wolframalpha.Client("L77A8L-97HJHAGAKQ") with th API key from wolframalpha is initialized and the result of the query is subsequently stored
    result=client.query(query); answer=next(result.results).text. try catch block is applied just in case wolframalpha does not have the answer,
    query=query.replace('Nora',''); results=wikipedia.summary(query,sentence=2), this redirects the answer from wikipedia. Another try catch block is applid in nested manner

    just in case even if wikipedia does not have the answer.
    uery = query.replace('Nora', '');webbrowser.open('https://google.com/?#q='+query):this redirects to Google search.Thus the query bot function remains error less.

    Download Complete Code

    Comments

    Comments for the packet "Virtual Assistant answers questions from WolframAlpha and Wikipedia in Python";
    No comments yet