Introduction to “alpha” – Your Personal Voice Assistant. Imagine having a knowledgeable and attentive companion at your beck and call, ready to assist with a wide range of tasks and provide information at your command. Meet “alpha0698,” your very own voice-controlled virtual assistant!
Alpha is a cutting-edge voice assistant designed to make your daily life easier and more enjoyable. With the power of voice recognition and intelligent responses, it’s like having a personal assistant right in your computer or device.
- Importing Libraries:
- The script starts by importing necessary libraries such as
speech_recognition
,pyttsx3
,webbrowser
,datetime
,pyjokes
,os
,requests
,BeautifulSoup
,wikipedia
, andpywhatkit
.
- The script starts by importing necessary libraries such as
- Listening and Recognizing Commands:
- The
sptext
function uses thespeech_recognition
library to capture audio input from a microphone and then recognizes the speech using Google’s speech recognition service. If the input is recognized, it returns the text data.
- The
- Text-to-Speech Conversion:
- The
speechtx
function uses thepyttsx3
library to convert text to speech. It initializes a text-to-speech engine, sets properties like voice and rate, and then speaks the given text.
- The
- Initial Greeting:
- The virtual assistant greets the user with the message “hello! This is alpha! What is the password?” and waits for a response.
- Main Loop:
- If the user responds with “hello alpha,” the assistant acknowledges and enters a loop to listen for further commands.
- Command Handling:
- Within the loop, the assistant listens for various commands and responds accordingly. Some of the recognized commands include:
- Greetings like “hello,” “how are you,” and responses like “I am fine.”
- Providing information about itself.
- Reporting the time and date.
- Telling jokes.
- Providing weather information (based on a Google search).
- Opening YouTube videos (using both
webbrowser
andpywhatkit
). - Opening the ChatGPT website.
- Playing songs from a specified directory.
- Searching and summarizing information from Wikipedia.
- Conducting Google searches and providing summarized results.
- Exiting the assistant.
- Within the loop, the assistant listens for various commands and responds accordingly. Some of the recognized commands include:
- Password Protection:
- If the initial password “hello alpha” is not recognized, the assistant responds with “Wrong Password.”
import speech_recognition as sr import pyttsx3 import webbrowser import datetime import pyjokes import os import requests from bs4 import BeautifulSoup import wikipedia import pywhatkit def sptext(): recognizer=sr.Recognizer() with sr.Microphone()as source: print("Listening...") recognizer.adjust_for_ambient_noise(source) audio=recognizer.listen(source) try: print("recognizing...") data=recognizer.recognize_google(audio) print(data) return data except sr.UnknownValueError: print("Not Understand") speechtx('Not understand') def speechtx(x): engine=pyttsx3.init() voices=engine.getProperty('voices') engine.setProperty('voice',voices[1].id) rate=engine.getProperty('rate') engine.setProperty('rate',150) engine.say(x) engine.runAndWait() speechtx('hello!this is alpha! What is the password?') if __name__=='__main__': while True: if "hello alpha" in sptext().lower(): speechtx('got it ! How can i help you? ') while True: data1=sptext().lower() if "hello" in data1: hello="Hello sir, how are you?" speechtx(hello) elif "yourself" in data1: tell="hi! I am you voice assistant, my name is alpha0698, i am here to assist you" speechtx(tell) elif "are you doing" in data1: doing="Nothing sir, i am waiting for your command" speechtx(doing) elif "where are you" in data1: where=" So, turn left from the paanwala and then go straight till you see a Banyan tree. Just kidding, ha ha ha ha, i live in the jupyter Notebook." speechtx(where) elif "morning" in data1: morning="Very Good Morning sir" speechtx(morning) elif " afternoon" in data1: afternoon="Very Good afternoon sir" speechtx(afternoon) elif " evening" in data1: e="Very Good Evening Sir" speechtx(e) elif "i am fine" in data1: fine="that's great sir" speechtx(fine) elif "how are you" in data1: perfect="Perfect sir" speechtx(perfect) elif "thank you" in data1: thank="you are welcome sir" speechtx(thank) elif "name" in data1: name="my name is alpha" speechtx(name) elif "old are you" in data1: age="i was launched in few days ago, so technically i'm pretty young." speechtx(age) elif "temperature" in data1: search="temperature in Bhubaneswar" url=f"https://www.google.com/search?q={search}" recognizer=requests.get(url) data=BeautifulSoup(recognizer.text,"html.parser") temp=data.find("div",class_="BNeawe").text speechtx(f"current{search}is{temp}") elif "time" in data1: time=datetime.datetime.now().strftime("%I%M%p") speechtx(time) elif "date" in data1: current_date=datetime.date.today() speechtx(current_date) elif "joke" in data1: joke=pyjokes.get_joke(language='en',category='neutral') print(joke) speechtx(joke) elif "youtube" in data1: speechtx("This is what i found for you search!") d=data1.replace("youtube search","") d=data1.replace("youtube","") d=data1.replace("alpha","") web="https://www.youtube.com/results?search_query=" + d webbrowser.open(web) pywhatkit.playonyt(data1) speechtx("Done, Sir") elif "chatgpt" in data1: speechtx("yeah opening") webbrowser.open("https://chat.openai.com/") elif "play song" in data1: add="C:\music" listsong=os.listdir(add) print(listsong) os.startfile(os.path.join(add,listsong[1])) elif "wikipedia" in data1: speechtx("searching from wikipedia...") l=data1.replace("wikipedia","") l=data1.replace("search wikipedia","") l=data1.replace("alpha","") results=wikipedia.summary(data1,sentences=3) speechtx("According to Wikipedia") print(results) speechtx(results) elif "google" in data1: import wikipedia as googleScrap t=data1.replace("alpha","") t=data1.replace("google search","") t=data1.replace("google","") speechtx("This is what i found on google") try: pywhatkit.search(data) result=googleScrap.summary(data1,1) speechtx(result) except: speechtx("No speakable output available") elif "exit" in data1: speechtx("Thank you") break else: print('Wrong Password') speechtx('Wrong Password')
Output:
Conclusion – Elevate Your Digital Experience with “alpha”
In a world where technology meets convenience, “alpha” emerges as your personal voice-controlled assistant. It listens, responds, and empowers your digital life with ease.Alpha0698 delivers quick weather updates, humor, music, and information at your command. Beyond that, it’s a project of endless potential, ready for your customization.
In this era of seamless human-computer interaction, alpha0698 is your bridge to knowledge, entertainment, and assistance through your voice. Welcome to a future where “alpha0698” amplifies your digital journey.
Explore, engage, and embrace the possibilities with “alpha.”