I Guess This Will Be Finnal
I Guess This Will Be Finnal
I Guess This Will Be Finnal
Submitted By
1. Overview 1
2. Abstract 3
3. Requirements 5
4. Modules 11
5. Build-in functions 15
6. Source code 19
7. Output 29
8. Conclusion 37
9. Future outlook 38
10. References 39
Overview:
Python is a high-level, interpreted, interactive and object-oriented scripting
language. Python is designed to be highly readable. It uses English keywords
frequently where as other languages use punctuations, and it has fewer
syntactical constructions than other languages.
Python features:
Page 1 of 39
Databases: Python provides interfaces to all major commercial
databases.
Portable: Python can run on a wide variety of hardware platforms and
has the same interface on all platforms.
Extendable: you can add low level modules to the interpreter and
enable you to add or customize their tools to be more efficient.
GUI programming: Python supports GUI applications that can be
created and ported to many system calls, libraries, and windows
systems, such as windows MFC, macintosh and the X windows system
of UNIX.
Incorporation: it can easily be integrated with other languages such
as C, C++, COM, ActiveX, Java etc.
Scalable: Python provides a better structure and support for large
programs than shell scripting.
Page 2 of 39
Abstract
Synopsis:
The “Voice-Wizzy” project is a Python-based application that listens to voice
commands and responds accordingly. Users can control the assistant with spoken
instructions, such as playing YouTube videos, searching the web, or obtaining
information from Wikipedia. It combines speech recognition and text-to-speech
synthesis for a convenient and interactive user experience. It also allows you to play
basic games.
The aim of the “Voice-Wizzy” program is to create an intuitive and user-friendly voice-
controlled personal assistant. This program seeks to enhance user convenience by
offering hands-free access to various functions, including web searches, multimedia
playback, and information retrieval. The primary goals are:
1.Efficiency
2.Accessibility
3.Demonstration
4.User Engagement
Ultimately, the program aims to make technology more accessible and user-centric
by enabling users to interact with their computers naturally and efficiently through
voice commands.
Page 3 of 39
Addressing real-world needs with a practical solution for daily tasks,
contributing to the evolution of human-computer interaction.
Acquisition of a skill set ready for the future, blending programming expertise
with an understanding of user-centric technology applications.
Page 4 of 39
Requirements
Hardware:
Processor: Intel or AMD 64-bit processor
Speaker or Headphones
Microphone
Software:
An operating system: Python is cross-platform and will work on Windows,
macOS, and Linux.
An IDE or code editor: There are many different IDEs and code editors that
support Python development. Some popular options include Visual Studio
Code, PyCharm, and Eclipse.
User manual
Running the “voice-wizzy”
[Python Downloads](https://www.python.org/downloads/)
Page 5 of 39
Step 2: Install Required Libraries
Step 5: Setting up
4.Replace the highlighted part with the image directory for speech button
Page 6 of 39
Step 4: Run the Script
‘python voice-wizzy.py’
Note:
1. Voice Recognition
Microphone Icon:
Voice Commands:
Page 7 of 39
"search" to perform a Google search.
2. Web Navigation
Navigation Buttons:
Special Functions:
3. Weather Information
Weather Display:
4. Task Management
Task List:
Page 8 of 39
Use the "Add Task" button to add tasks to the list.
5. Hangman Game
Hangman Window:
Additional Tips:
Customizable Commands:
Enjoy Multifunctionality:
Make a new folder with any title and save the python code in the
folder.
Save the ‘icon’ image with ‘.ico’ extension in the same extension.
Page 9 of 39
Save the ‘voice-recognition’ image with ‘.png’ extension in the same
extension
Copy the paths of both files and paste it in the required places
Then install the required modules as mentioned
Page 10 of 39
Modules
Python modules are self-contained units of code, encapsulating functions,
classes, and variables. They promote code reusability, organization, and
encapsulation, allowing developers to create modular and scalable
programs. Modules are imported using the `import` statement, providing a
way to structure code and manage namespaces for more efficient and
maintainable development.
The modules used in this project is listed below:
Page 11 of 39
such as Google Web Speech API, it simplifies tasks like transcription and
enhances user interactions in applications
5. Time: The `time` module in Python serves as a versatile tool for handling
time-related operations. From measuring execution durations and
introducing delays to formatting and displaying timestamps, it offers
essential functionalities. Developers commonly leverage it for tasks
involving temporal aspects, making it a fundamental component of
Python's standard library. Whether calculating intervals or managing
timestamps, the `time` module provides a reliable foundation for handling
time in Python scripts.
Page 12 of 39
7. Googlesearch: The googlesearch library in Python facilitates web
searches using the Google Search engine. It provides a simple interface to
perform searches, retrieve results, and access relevant information from
the web. Leveraging the power of Google's search algorithms, this library
enables developers to integrate dynamic and real-time web search
capabilities into their Python applications. With straightforward usage and
the ability to fetch search results programmatically, googlesearch is a
valuable tool for projects requiring access to up-to-date information from
the vast expanse of the internet.
Page 13 of 39
10. Pycountry: pycountry is a Python library offering easy access to ISO
standards for country-related information. It simplifies tasks like retrieving
country details, obtaining country codes, and accessing regional
subdivisions. With comprehensive coverage and bi-directional mapping,
pycountry is lightweight, making it ideal for geographical data processing,
localization, and data enrichment tasks. Its installation is straightforward
using pip, and it proves valuable for projects requiring standardized
country information and code validation.
Page 14 of 39
Build-in functions
Built-in functions in Python are pre-defined functions that are part of the
Python programming language. They are readily available for use without
the need for explicit import statements. These functions serve various
purposes and are designed to perform common tasks, making them
fundamental to the language. Examples include functions for input/output,
data manipulation, mathematical operations, string processing, and more.
Built-in functions simplify programming by providing a set of ready-to-use
tools, enhancing the efficiency and expressiveness of Python code.
Developers can leverage these functions without creating them from scratch,
promoting code reusability and readability.
1.Tkinter:
i)tk.Tk(): Initializes the main application window, serving as the
foundation for the entire Tkinter graphical user interface.
iv)tk.Entry(): Generates entry widgets for user input, enabling the capture
of single-line textual data.
vi)tk.Text(): Creates text widgets for multiline text, facilitating the display
and editing of extended textual information.
Page 15 of 39
x)tk.Frame(): Establishes frames for organizing and grouping widgets,
contributing to a structured and modular GUI layout.
xiv)mainloop(): Initiates the main event loop, allowing the graphical user
interface to continuously respond to user inputs and events.
2.pycountry:
3.requests:
4.googlesearch:
5.pyttsx3:
Page 16 of 39
ii)speech.say(): Converts text to speech and queues it for playback.
speech is finished.
6.webbrowser:
7. speech_recognition:
8.Pillow (PIL):
Page 17 of 39
v)ImageTk.PhotoImage(): The `ImageTk.PhotoImage()` constructor
converts a Pillow image into a Tkinter-compatible PhotoImage object. This
conversion is essential for displaying images within Tkinter applications.
Random:
Time:
ii)sleep(): The sleep() function pauses the execution of the program for a
specified number of seconds.
Page 18 of 39
Source code:
import tkinter as tk
from PIL import Image, ImageTk
import speech_recognition as sr
import webbrowser
from time import strftime, sleep
import pyttsx3#for text to speech
from googlesearch import search
import requests
from tkinter import messagebox
import random
import pycountry
# assined as none
lbl, t_entry, root, img_speech = None, None, None, None
word, guesses, life_points = "", [], 6 # Initialize hangman game variables
word_label = None#
def add_task():#todo list
task = task_entry.get()#geting input
if task:
tasks.append(task)
task_listbox.insert(tk.END, task)
task_entry.delete(0, tk.END) # Clearing entry field
else:
messagebox.showinfo("Empty Task", "Please enter a task.")
def remove_task():
selected_index = task_listbox.curselection()#a selection tool
if selected_index:
task_index = selected_index[0]
del tasks[task_index]#removes from the list
task_listbox.delete(task_index)
else:
messagebox.showinfo("No Task Selected", "Please select a task to
remove.")
tasks = []
def get_places():
place = list(country.name for country in pycountry.countries)
#the first letter is lowwered
places = [word[:1].lower() + word[1:] for word in place]
return places#a list of country name
def get_display_word():
display_word = ""
for letter in word:
Page 19 of 39
if letter in guesses:
display_word += letter
else:
display_word += "_"
return display_word
def make_guess():
global life_points
guess = guess_entry.get().lower()
if len(guess) == 1 and guess.isalpha():
if guess in guesses:
messagebox.showinfo("Invalid Guess", "You already
guessed this letter.")
else:
guesses.append(guess)
display_word = get_display_word()
word_label.config(text=display_word)
def reset_game():
global word, guesses, life_points
word = random.choice(word_list)
guesses = []
life_points = 6
word_label.config(text=get_display_word())
guessed_label.config(text="Guessed Letters: ")
life_label.config(text=f"Life Points: {life_points}")
def open_hangman_window():
# Initialize the word list with places
Page 20 of 39
global word_list # Make word_list global
word_list = get_places()
Page 21 of 39
except requests.exceptions.RequestException as e:
print(f"Error fetching weather data: {e}")
return None
params = {
'access_key': api_key,
'query': city
}
try:
response = requests.get(base_url, params=params)
response.raise_for_status()
weather_data = response.json()
return weather_data
except requests.exceptions.RequestException as e:
print(f"Error fetching weather data: {e}")
return None
if data:
temperature = data['current']['temperature']
description = data['current']['weather_descriptions'][0]
label_temperature.config(text=f"Temperature: {temperature}°C")
label_description.config(text=f"Description: {description}")
else:
messagebox.showerror("Error", "Error fetching weather data.")
def f_voice(speech_engine):
# Configure text-to-speech voice
voices = speech_engine.getProperty('voices')
speech_engine.setProperty('voice', voices[1].id) # Adjust the index based on available
voices
def speech_output(text):
# Convert text to speech
Page 22 of 39
speech = pyttsx3.init()
f_voice(speech)
speech.say(f"sir: {text}")
speech.runAndWait()
def on_click(event):
voice_recognition() # the voice button click event
def button_click(site):
if site == "Speech":
voice_recognition()
elif site == "chess":
open_chess()
elif site == "neon pong":
open_pong()
else:
webbrowser.open(w_urls.get(site, "https://www.google.com"))
def open_pong():
url = "https://www.msn.com/en-in/play/games/neon-pong/cg-9pkb2m30zbv9
?cgfrom=cg_shoreline_l1recommended&ocid=cghubl1&form=MT0072&
hideNativeSidebar=1&cvid=f414c5217ae04e51b13d4761070b672c&ei=18"
webbrowser.open(url)
def open_chess():
url = "https://www.msn.com/en-in/play/games/master-chess/cg-
9pkb2m30zbv9?cgfrom=cg_shoreline_l1recommended&ocid=
cghubl1&form=MT0072&hideNativeSidebar=1&cvid=f414c5
217ae04e51b13d4761070b672c&ei=18"
webbrowser.open(url)
def the_boss(_link):
try:
result = search(_link, stop=1)
link = next(result, None)
if link:
webbrowser.open(link)
else:
txt = "No search results found."
t_entry(tk.END, f'{txt}')
print("No search results found.")
except Exception as e:
print(f"An error occurred: {e}")
Page 23 of 39
def voice_recognition():
recorder = sr.Recognizer()
try:
with sr.Microphone() as AUDIO:
print("Say Something...")
t_entry.delete("1.0", tk.END)
t_entry.insert(tk.END, f"say something.....")
recorder.adjust_for_ambient_noise(AUDIO, duration=0.8)
audio = recorder.listen(AUDIO)
print("TIME OVER")
t_entry.delete("1.0", tk.END)
t_entry.insert(tk.END, f"TIME OVER.")
text = recorder.recognize_google(audio)
t_entry.delete("1.0", tk.END)
t_entry.insert(tk.END, f"You said: {text}\n")
if "YouTube" in text :
txt = "opening youtube"
t_entry.insert(tk.END, f"{txt}")
video_query = text.replace("YouTube", "")
speech_output(txt)
webbrowser.open(f"https://www.youtube.com/results?search_query
={video_query}")
Page 24 of 39
webbrowser.open(wikipedia_url)
except sr.UnknownValueError:
a = "sir i could not understand audio."
speech_output(a)
t_entry.insert(tk.END, f"{a}")
except sr.RequestError as e:
a = f" I Could not request results or maybe its a network issue; {e}"
speech_output(a)
t_entry.insert(tk.END, f"{a}")
except Exception as e:
a = f"An error occurred: {e}"
t_entry.insert(tk.END, f"{a}")
speech_output(a)
def close():
t_entry.insert(tk.END, "closing the application")
sleep(1)
root.destroy()
def time():
string = strftime('%d-%m-%Y-|-%I:%M:%S %p')
lbl.config(text=string)
lbl.after(1000, time)
w_urls = {
"Google": "https://www.google.com",
"Youtube": "https://www.youtube.com",
"Mail": "https://mail.google.com",
"Wikipedia": "https://www.wikipedia.org",
Page 25 of 39
"whatsapp": "https://web.whatsapp.com/",
"Music": "https://wynk.in/music",
"Ssm website": "https://ssmetrust.in/ssm63/default.aspx"
}
def main():
global lbl, t_entry, root, img_speech, task_entry, task_listbox
api_key = '383ab22653eaf8f8a69284a15952ab00'
city_name = 'Chennai'
root = tk.Tk()
root.title("voice-wizzy")
root.iconbitmap(r"D:\gokul files\New folder\icon.ico")
for i, b in enumerate(button_list):
if b == "Hangman":
create_button(root, b, i + 1, 1, open_hangman_window)
else:
create_button(root, b, i + 1, 1, lambda site=b:
button_click(site))
Page 26 of 39
t_entry.insert(tk.END, "This code is a Tkinter-based application\n"
"for voice-controlled website navigation.\n"
"It features buttons for Google, YouTube, Gmail,
Wikipedia, and voice \n"
"recognition. The output window displays
Voice recognition\n"
"results and actions taken ")
# Example:
lbl = tk.Label(root, font=('calibri', 40, 'bold'), background='#FFFFFF',
foreground='#4E342E') # Brown
# Example:
label_temperature = tk.Label(root, text="Temperature: Loading...",
bg='#FFFFFF') # Light Blue
# Example:
todo_frame = tk.Frame(root, bg='#CDCDC1')
todo_frame.grid(row=0, column=3, rowspan=5, padx=10, pady=20,
sticky="nsew")
add_button.pack(pady=5)
task_listbox.pack(pady=10)
Page 27 of 39
command=remove_task, font=('Helvetica', 16))
remove_button.pack(pady=5)
if __name__ == "__main__":
main()
Page 28 of 39
OUTPUT
Hangman:
Page 29 of 39
Whatsapp:
Wikibutton:
Page 30 of 39
Chess:
Neon pong:
Page 31 of 39
Music:
Google:
Page 32 of 39
Youtube:
Ssmwebsite:
Page 33 of 39
Outputs for voice activated
Open youtube:
Play Perfect:
Page 34 of 39
search monkey:
tell monkey:
Page 35 of 39
Open lenskart:
Page 36 of 39
Conclusion
Page 37 of 39
Future Outlook
Our vision extends beyond the current project scope. We aspire to transform
this application into a mobile-friendly platform, eliminating the need for Wi-
Fi dependency. Inspired by popular voice assistants in mobile phones, our
goal is to enable users to activate the application solely through voice
commands, enhancing accessibility.
Page 38 of 39
References
https://developer.spotify.com/documentation/web-api/reference/seek-to-
position-in-currently-playing-track
https://developer.spotify.com/documentation/web-api
https://github.com/17-karthick-03
https://www.geeksforgeeks.org/python-gui-tkinter/?ref=header_search
https://www.geeksforgeeks.org/python-launch-a-web-browser-using-
webbrowser-module/?ref=header_search
https://www.geeksforgeeks.org/python-requests-
tutorial/?ref=header_search
These are links which helped us on using various modules and learning how
to utilize them to their fullest.
Page 39 of 39