Skip to content

Friday.py Explained

Mohammed Zameel ali edited this page May 17, 2023 · 2 revisions

Importing Libraries: The program starts by importing various libraries required for different functionalities such as speech recognition, text-to-speech, web scraping, email sending, image processing, etc.

Class Definitions: Two classes, namely "Person" and "Friday", are defined to store and retrieve the user's name and the assistant's name, respectively.

Function Definitions:

  1. speak: This function uses the gTTS library to convert text to speech and save it as an audio file.

  2. wish: It greets the user based on the current time and introduces the assistant.

  3. jokes: This function generates and speaks a random joke using the pyjokes library.

  4. email: Allows the user to send emails by providing the necessary information like email address, password, receiver's email address, and message.

  5. quotes: Retrieves and speaks a random quote.

  6. news: Fetches the latest news headlines using the News API and speaks them.

  7. days: Tells the user the current day.

  8. date: Tells the user the current date.

  9. screenshot: Takes a screenshot of the screen using the pyautogui library.

  10. ask: Uses the Wolfram Alpha API to answer computational questions asked by the user.

  11. calender: Opens the Google Calendar in a web browser.

  12. note: Allows the user to write a voice note and saves it to a text file.

  13. wiki: Searches Wikipedia and speaks a summary of the search result.

  14. read_note: Reads the previously saved voice note from the text file.

  15. cmd: Opens the command prompt/terminal.

  16. ip: Retrieves and speaks the user's IP address.

  17. cpu: Provides information about CPU usage and battery status.

  18. cam: Opens the front webcam and displays the video feed.

  19. stock: Performs a Google search for stock market information.

  20. pdf_reader: Reads the content of a PDF file provided by the user.

  21. time_now: Tells the current time.

  22. support: Opens the link to the software's GitHub repository.

  23. youtube: Performs a YouTube video search based on user input.

  24. google: Performs a Google search based on user input.

  25. route_to: Opens Google Maps with directions to the specified location.

  26. wiki_step_mode: Activates a "how to" mode and provides step-by-step instructions.

  27. Setup and Introduction: The program includes functions to play startup and introduction audio files.

  28. Neural Intents and Mapping: The program uses the Neural Intents library to define and train a model for understanding user queries and mapping them to appropriate functions.

Main Thread: The MainThread class handles the main execution of the program. It includes methods for speech recognition, handling user queries, and running the assistant's responses in the background.

Main GUI: The Main class creates the graphical user interface using the PyQt5 library and connects the UI elements to the corresponding functions.

Application Execution: The program creates an instance of the GUI class, shows the UI, and starts the event loop to execute the application.

Overall, the program combines different functionalities and provides a conversational interface for the virtual assistant "Friday." The user can interact with the assistant by speaking voice commands, and the assistant responds accordingly by performing various tasks such as providing information, opening websites, sending emails, and more.

Clone this wiki locally