0% found this document useful (0 votes)
53 views41 pages

I Guess This Will Be Finnal

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 41

CREATION OF VOICE-WIZZY

A COMPUTER SCIENCE PROJECT REPORT

Submitted By

GOKUL B, Class XI-‘F’

PRANNAV BAARADI S, Class XI-‘F’

SRIMATHI SUNDARAVALLI MEMORIAL SCHOOL,


CHENNAI
TABLE OF CONTENTS

S.NO CONTENT PAGE NO.

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 is beginner friendly: Python is a great language for the beginner-


level programmers and supports the development of a wide range of
applications from simple text processing to www browser games.
 Python is interactive: You can sit in a python prompt and interact with
the interpreter directly to write your programs.
 Python is interpreted: Python is processed at runtime by the interpreter.
You do not need to compile your program before executing it. This is
similar to PERL and PHP.
 Python is object oriented: Python supports object-oriented style of
technique of programming that encapsulates code within objects.

Python features:

Python features include –

 Easy-to-learn: Python has few keywords, simple structure and a


clearly defined syntax. This allows the student to pick up the language
quickly.
 Easy-to-read: Python code is more clearly defined and visible to the
eyes.
 A broad standard library: Python’s bulk of library is very portable and
cross-platform compatible on UNIX, windows and macintosh.
 Easy-to-maintain: Python has support for an interactive mode which
allows interactive testing and debugging of snippets of code.

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.

Reason for choosing this project:


 Creation of a hands-free, interactive user experience, aligning with the trend
of accessible and intuitive computing.

 Implementation of cutting-edge voice commands for web searches, task


automation, and personalized assistance.

 Integration of dynamic entertainment features, offering a perfect balance


between productivity and enjoyment.

 Development of a tailored assistant catering to individual preferences, adding


a personalized touch to the user experience.

 Embarking on an educational journey into emerging technologies, providing


insights into natural language processing and voice technology.

Page 3 of 39
 Addressing real-world needs with a practical solution for daily tasks,
contributing to the evolution of human-computer interaction.

 Demonstration of technical prowess in Python, covering Tkinter, web


interactions, and versatile module integrations.

 Creation of a standout portfolio piece, showcasing creativity and technical


competence in the development of an innovative application.

 Acquisition of a skill set ready for the future, blending programming expertise
with an understanding of user-centric technology applications.

 Exploration of industry-relevant trends in voice-controlled applications,


reflecting an awareness of innovative and accessible solutions.

Page 4 of 39
Requirements
Hardware:
 Processor: Intel or AMD 64-bit processor

 Memory: 4 GB RAM (8 GB preferred)

 Disk space: 5 GB available hard disk space(15 GB preferred)

 Internet connection: An internet connection is required to download and


install Python 3.12.

 Speaker or Headphones

 Microphone

Software:
 An operating system: Python is cross-platform and will work on Windows,
macOS, and Linux.

 Python 3.6 or later

 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.

 A Python distribution: A Python distribution is a collection of Python packages


and modules that are installed together. Some popular Python distributions
include Anaconda and Miniconda.

 Some required files

User manual
 Running the “voice-wizzy”

Step 1: Install Python

Ensure you have Python 3.12 installed on your system. If not,


download and install it from the official Python website:

[Python Downloads](https://www.python.org/downloads/)

Page 5 of 39
Step 2: Install Required Libraries

Open a terminal or command prompt and run the following


commands to install the necessary Python libraries:

Sample input on the terminal:

‘pip install Pillow SpeechRecognition pyttsx3 googlesearch-python


requests pycountry’

Step 3: Download the Code

Download the Python script (`voice-wizzy.py`) and any associated files


to a directory on your computer.

Step 5: Setting up

1.Open the program file you downloaded in python IDLE

2.Copy the path of the mic_button image

3.Paste the path into program file in line

4.Replace the highlighted part with the image directory for speech button

5.again repeat the same

6.Copy the path of the icon image

7.Paste it in the highlighted area

Page 6 of 39
Step 4: Run the Script

Execute the Python script using the following command:

‘python voice-wizzy.py’

Step 5: Explore the Features

The ‘voice-wizzy’ GUI will open, featuring buttons for various


functions. Explore the features such as voice recognition, web
navigation, weather information, task management, and the Hangman
game.(A brief exploration manual is given below)

Step 6: Exiting the Application

Click the "Close" button to exit the application.

Note:

- Ensure an active internet connection for web-related functionalities.

- Adjust the paths and commands based on your operating system


(commands may vary for Windows, macOS, and Linux).

 All-in-One Wizard Exploration Manual

1. Voice Recognition

 Microphone Icon:

 Click on the microphone icon to initiate voice recognition.

 Wait for the "Say Something..." prompt.

 Voice Commands:

 Use voice commands like:

 "YouTube" to search YouTube.

Page 7 of 39
 "search" to perform a Google search.

 "tell about" to search Wikipedia.

 "time" to get the current time.

 “open” to open any websites

 “close” to close the program

 “play” to open the wised song

2. Web Navigation

 Navigation Buttons:

 Explore various buttons such as Google, YouTube, Mail, etc.

 Click on a button to open the default web browser with the


specified website.

 Special Functions:

 "Hangman" button opens a Hangman game.

 "Refresh Weather" button fetches the latest weather information.

3. Weather Information

 Weather Display:

 Click on "Refresh Weather" to get the latest weather information


for Chennai.

 Temperature and weather description will be displayed.

4. Task Management

 Task List:
Page 8 of 39
 Use the "Add Task" button to add tasks to the list.

 Click on a task in the list to select it.

 Click "Remove Task" to delete the selected task.

5. Hangman Game

 Hangman Window:

 Click on the "Hangman" button to open the Hangman game


window.

 Guess letters to uncover the hidden word.

 The game provides feedback on guessed letters and life points.

Additional Tips:

 Explore Voice Commands:

 Experiment with different voice commands for web searches,


Wikipedia, and entertainment.

 Customizable Commands:

 Consider modifying the script to add more personalized voice


commands or web navigation options.

 Enjoy Multifunctionality:

 This program serves as an all-in-one assistant, balancing


entertainment and productivity.

Setting up reference path:

 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:

1. Tkinter: Tkinter, a Python library, simplifies GUI creation with elegance


and ease. Leveraging the Tk GUI toolkit, it enables developers to craft
intuitive interfaces effortlessly. With just a few lines of code, windows,
buttons, and other widgets come to life. Tkinter's straightforward syntax
and event handling empower both beginners and seasoned programmers.
Despite its simplicity, the library supports diverse widgets and features,
making it a versatile choice for building interactive applications. Whether
you're a novice or an expert, Tkinter remains a powerful tool for bringing
user-friendly graphical interfaces to Python projects.

2. Pillow(pil): PIL, or the Python Imaging Library, is a library for opening,


manipulating, and saving many different image file formats. It provides a
set of modules and classes for working with images, including basic image
processing operations like cropping, resizing, and filtering. PIL was the
original name of the library, but later development transitioned to the
Pillow library, which is a more actively maintained fork of PIL. Pillow
retains compatibility with PIL and extends its capabilities, making it a
popular choice for image processing tasks in the Python programming
language.

3. Speech recognition: Speech recognition, a technology transforming


spoken words into text, finds application in programming through libraries
like SpeechRecognition in Python. This enables developers to integrate
voice-controlled features effortlessly. With support for various engines,

Page 11 of 39
such as Google Web Speech API, it simplifies tasks like transcription and
enhances user interactions in applications

4. Webbrower: `webbrowser` is a Python module facilitating easy interaction


with web browsers. With a simple interface, it enables developers to open
URLs in the default browser effortlessly. Whether displaying
documentation or launching web applications, the `webbrowser` module
streamlines the process, offering a quick solution for integrating web
content into Python scripts.

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.

6. Pyttsx3: `pyttsx3` is a Python library facilitating text-to-speech


conversion. With an intuitive interface, it enables developers to incorporate
spoken output into their Python applications effortlessly. The library
supports configuration options, allowing customization of speech
parameters like rate. From enhancing accessibility features to creating
interactive voice-driven applications, `pyttsx3` serves as a versatile tool for
integrating text-to-speech capabilities in Python projects. Developers can
easily convert textual information into spoken words, expanding the
possibilities for user interaction and accessibility within their applications.

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.

8. Requests: The Python requests library streamlines HTTP requests,


offering a straightforward API for seamless interactions with web services.
Supporting common methods like GET, POST, PUT, and DELETE, it
simplifies parameter handling, enabling easy inclusion in URL query
strings and request bodies. With robust session management,
authentication support, and customizable headers, requests caters to
diverse web communication needs. It excels in API integration, web
scraping, and data retrieval, providing a reliable solution for fetching data
from RESTful APIs and external sources. With straightforward installation
via pip and widespread adoption, requests stands as a versatile and
essential tool in the Python ecosystem for handling HTTP interactions
effortlessly.

9. Random:The `random` module in Python is a versatile tool for introducing


unpredictability into your programs. Whether you're simulating chance
events, shuffling data, or generating random numbers, this module adds
a touch of spontaneity to your code. From creating games with randomized
elements to enhancing statistical simulations, the `random` module is your
companion in the realm of controlled chaos. Just remember, while
randomness might seem capricious, the `random` module allows you to
bring a touch of order to the unpredictable, adding both excitement and
realism to your Python projects.

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.

11. Pyaudio: PyAudio is a Python library that simplifies audio I/O


operations, allowing developers to easily capture and play audio. Built on
the cross-platform PortAudio library, PyAudio supports real-time audio
processing and provides a flexible API for tasks like voice recognition,
multimedia applications, and communication tools. With seamless
integration with NumPy, it offers versatility in manipulating audio data.
Ideal for applications requiring audio interaction, PyAudio's simplicity and
compatibility make it a valuable tool for various projects. Installation is
straightforward using pip, and its use cases range from voice recognition
systems to real-time audio processing applications.

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.

ii)tk.Button(): Creates interactive buttons, facilitating user-triggered


actions and enhancing the GUI's responsiveness.

iii)tk.Label(): Constructs text or image labels, providing informative


elements within the graphical user interface.

iv)tk.Entry(): Generates entry widgets for user input, enabling the capture
of single-line textual data.

v)tk.Listbox(): Constructs listboxes to display and manage lists of items,


offering organized content presentation.

vi)tk.Text(): Creates text widgets for multiline text, facilitating the display
and editing of extended textual information.

vii)tk.Toplevel(): Generates additional top-level windows, enhancing the


application's structure and accommodating diverse functionalities.

viii)messagebox.showinfo(): Displays information message boxes,


providing users with contextually relevant information or updates.

ix)messagebox.showerror(): Presents error message boxes, alerting users


to critical issues or unexpected errors within the application.

Page 15 of 39
x)tk.Frame(): Establishes frames for organizing and grouping widgets,
contributing to a structured and modular GUI layout.

xi)pack(): Serves as a geometry manager for organizing widgets, assisting


in the positioning and alignment of graphical elements.

xii)grid(): Functions as a geometry manager for arranging widgets in a grid


format, facilitating systematic and flexible layout designs.

xiii)bind(): Binds events, such as button clicks, to specific functions,


enabling the execution of actions in response to user interactions.

xiv)mainloop(): Initiates the main event loop, allowing the graphical user
interface to continuously respond to user inputs and events.

2.pycountry:

i)pycountry.countries: Returns a list of `Country` objects representing


all countries, allowing access to details like name and alpha-2 code.

ii)pycountry.name: Retrieves the name of a country from a `Country`


object.

3.requests:

i)requests.get(): Sends an HTTP GET request to the specified URL,


retrieving the content of the response.

ii)response.raise_for_status(): Checks the response for errors and


raises an exception if the HTTP request was unsuccessful.

4.googlesearch:

i)search(): Initiates a Google search and returns an iterator of search


results.

5.pyttsx3:

i)pyttsx3.init(): Initializes a text-to-speech engine.

Page 16 of 39
ii)speech.say(): Converts text to speech and queues it for playback.

iii)speech.runAndWait(): Blocks the program until all currently queued

speech is finished.

6.webbrowser:

i)webbrowser.open(): Opens a web page or document in the user's


preferred web browser.

7. speech_recognition:

i)Recognizer(): Initializes a speech recognition engine.

ii)recorder.listen(): Captures audio input from the microphone.

iii)recorder.adjust_for_ambient_noise(): Adjusts the microphone


sensitivity for ambient noise.

iv)recorder.recognize_google(): Performs speech-to-text conversion


using the Google Web Speech API.

8.Pillow (PIL):

i)Image: The `Image` module in Pillow supports the opening, manipulating,


and saving of various image formats. it serves as the core module for image-
related operations.

ii)ImageTk: The `ImageTk` module facilitates the seamless integration of


Pillow images with Tkinter. It provides functions for converting Pillow images
to Tkinter PhotoImage objects, allowing easy display in Tkinter GUIs.

iii)Image.open(): The `Image.open()` method opens an image file, enabling


subsequent operations such as resizing, cropping, or applying filters.

iv)Image.resize(): The `Image.resize()` method adjusts the size of an


image, either maintaining or disregarding the original aspect ratio based on
specified dimensions.

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:

i)random.choice(): Returns a randomly selected element from a


sequence (e.g., a list).

Time:

i) strftime(): The strftime() function formats the current time according to


the specified format.

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)

if guess not in word:


life_points -= 1

guessed_label.config(text=f"Guessed Letters: {' '.join(guesses)}")


life_label.config(text=f"Life Points: {life_points}")

if "_" not in display_word:


messagebox.showinfo("Congratulations!", "You guessed the
word!")
reset_game()
if life_points == 0:
messagebox.showinfo("Game Over", f"Sorry, you ran out of life
points. The word was '{word}'.")
reset_game()
else:
messagebox.showinfo("Invalid Guess", "Please enter a single letter.")

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()

# Hangman window components


hangman_window = tk.Toplevel(root)
hangman_window.title("Hangman Game")

# Make word_label global


global word_label
word_label = tk.Label(hangman_window, text=get_display_word(),
font=('Helvetica', 24))
word_label.pack(pady=20)

hangman_guess_label = tk.Label(hangman_window, text="Guess a letter:",


font=('Helvetica', 16))
hangman_guess_label.pack()

global guess_entry # Make guess_entry global


guess_entry = tk.Entry(hangman_window, font=('Helvetica', 16))
guess_entry.pack()

hangman_guess_button = tk.Button(hangman_window, text="Guess",


command=make_guess, font=('Helvetica',
16))
hangman_guess_button.pack(pady=10)

global guessed_label, life_label # Make labels global


guessed_label = tk.Label(hangman_window, text="Guessed Letters: ",
font=('Helvetica', 16))
guessed_label.pack()

life_label = tk.Label(hangman_window, text=f"Life Points: {life_points}",


font=('Helvetica', 16))
life_label.pack()

def get_weather(api_key, city):


base_url = 'http://api.weatherstack.com/current'
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

Page 21 of 39
except requests.exceptions.RequestException as e:
print(f"Error fetching weather data: {e}")
return None

def get_weather(api_key, city):


# Get weather data from Weatherstack API
base_url = 'http://api.weatherstack.com/current'

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

def update_weather(api_key, city, label_temperature, label_description):


# Update weather information on the GUI
data = get_weather(api_key, city)

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 create_button(root, text, row, column, command=None):


# Function to create a button with the specified text and command
b = tk.Button(root, text=text, font=("Arial", 12), command=command)
b.grid(row=row, column=column, padx=10, pady=10, sticky="ew")

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}")

elif 'time' == text:


string = strftime('%I:%M %p')
speech_output(string)

elif "search" in text:


txt = "searching in google"
t_entry.insert(tk.END, f"{txt}")
search_query = text.replace("search", "")
speech_output(txt)
webbrowser.open(f"https://www.google.com/search?q={search_
query}")

elif "tell" in text:


txt = "searching in wikipedia"
t_entry.insert(tk.END, f"{txt}")
topic = text.replace("tell about", "")
speech_output(txt)
wikipedia_url= f"https://en.wikipedia.org/wiki
/{topic.replace('', '_')}"

Page 24 of 39
webbrowser.open(wikipedia_url)

elif "close" in text:


txt = "closing the application"
t_entry.insert(tk.END, f"{txt}")
close()

elif "play" in text:


query = text.replace("play", "")
url = f"https://open.spotify.com/search/{query}"
webbrowser.open(url)

elif "open" in text:


web_search = text.replace('open', '')
speech_output(text)
the_boss(web_search)

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")

root.config(bg='#DCDCDC') # Light Amber

# Use an image for the speech recognition button


img_speech = Image.open(r"D:\gokul files\New folder\voice-recognition.png")
img_speech = img_speech.resize((100, 100))
img_speech = ImageTk.PhotoImage(img_speech)

# Create the speech recognition button with the assigned image


speech_button = tk.Button(root, image=img_speech,
command=voice_recognition, bd=0)
speech_button.grid(row=0, column=0, padx=10, pady=10, rowspan=5,
sticky="nsew")
# List of buttons creates button in a loop

button_list = ["Google", "Youtube", "Mail", "Wikipedia", "whatsapp",


"Music", "Ssm website", "Hangman", "chess","neon pong"]

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))

t_entry = tk.Text(root, height=10, width=40)


t_entry.grid(row=0, column=2, rowspan=5, padx=10, pady=10, sticky="ew")

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

lbl.grid(row=0, column=1, padx=10, pady=10, sticky="e")

create_button(root, "Close", 6, 2, close)


time()

# Example:
label_temperature = tk.Label(root, text="Temperature: Loading...",
bg='#FFFFFF') # Light Blue

label_description = tk.Label(root, text="Description: Loading...",


bg='#FFFFFF') # Light Blue

label_temperature.grid(row=8, column=2, pady=10)


label_description.grid(row=9, column=2, pady=10)

# Example:
todo_frame = tk.Frame(root, bg='#CDCDC1')
todo_frame.grid(row=0, column=3, rowspan=5, padx=10, pady=20,
sticky="nsew")

task_entry = tk.Entry(todo_frame, font=('Helvetica', 16))


task_entry.pack(pady=10)

add_button = tk.Button(todo_frame, text="Add Task", command=add_task,


font=('Helvetica', 16))

add_button.pack(pady=5)

task_listbox = tk.Listbox(todo_frame, selectbackground="yellow",


selectmode=tk.SINGLE, font=('Helvetica', 16))

task_listbox.pack(pady=10)

remove_button = tk.Button(todo_frame, text="Remove Task",

Page 27 of 39
command=remove_task, font=('Helvetica', 16))

remove_button.pack(pady=5)

create_button(root, "Refresh Weather", 7, 2,


lambda: update_weather(api_key, city_name, label_temperature,
label_description))
time()
root.mainloop()

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:

Open canon india:

Page 36 of 39
Conclusion

In a broader sense, this project served as a bridge between classroom learning


and real-world application. The guidance we received acted as a compass,
steering us through the intricacies of coding and problem-solving. The
exposure to diverse modules not only enhanced our technical proficiency but
also sparked a curiosity to delve deeper into the vast realm of programming.
Despite the minor challenges, such as timing adjustments, every hurdle
became an opportunity to refine our skills. This project was not just a
culmination of lines of code; it was a journey of self-discovery, resilience, and
a testament to the transformative power of hands-on learning. As we conclude
this project, we carry forth a wealth of experiences that will undoubtedly
shape our future endeavors in the field of programming.

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.

In the upcoming update, we plan to introduce a groundbreaking feature – the


ability to establish text-based conversations with other users. This real-time
communication functionality aims to provide a seamless and interactive
experience within the application.

As technology continues to advance, our commitment is to stay at the


forefront of innovation. Future updates will focus on refining the user
experience and expanding the application's capabilities. We envision creating
a robust, user-friendly app that caters to the evolving needs of our audience.

Our development roadmap includes incorporating modern technologies,


exploring mobile device compatibility, and implementing intuitive voice
activation. This endeavor not only propels the project to new heights but also
serves as a continuous learning journey, honing our coding skills along the
way.

Anticipating the release of our app to the market, we are dedicated to


providing users – both current and future – with compelling reasons to
download and integrate our application into their daily lives. Through these
planned enhancements, we aim to establish our app as a valuable and
indispensable tool for a diverse user base.

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

Used to make the Spotify player.

https://github.com/17-karthick-03

got ideas on how to tackle problems from him.

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

You might also like