Creating a simple voice assistant in Python involves integrating several libraries for speech recognition, text-to-speech, and possibly natural language processing. Below is a complete example of a basic voice assistant using Python that can recognize speech, respond with voice, and perform some basic commands like web searches, time queries, and opening websites.
Required Python Packages
Install the necessary libraries using pip:
Note: If pyaudio fails to install, on Windows use:
Features in This Assistant
-
Speech Recognition: Converts your voice to text using Google Speech Recognition.
-
Text to Speech (TTS): Speaks back to the user using
pyttsx3. -
Command Execution: Recognizes and performs tasks like telling the time, opening websites, and searching the web.
This code offers a foundational voice assistant you can expand with more sophisticated capabilities like NLP, app control, or home automation.