You are on page 1of 11

Voice Assistant

24.01.2023
!

Jujhar Singh
Class XI-D
Roll No. :-32
Shri Guru Gobind Singh Public School
1

Certificate

This is to certify that the ……Voice


Assistant Project…….. is submitted by
………Jujhar Singh……. under the
supervision of …..(your teacher’s
name)……in the academic year…..2022-
2023……….

Sign of teacher Sign of external


2

Acknowledgement

I would like to convey my heartfelt


gratitude to Mrs. (Teacher’s Name) for
her tremendous support and
assistance in the completion of my
project. I would also like to thank our
Principal, Mrs. Pritinder Kaur for
providing me with this wonderful
opportunity to work on a project with
the topic Food Culture during the
Pandemic. The completion of the
project would not have been possible
without their help and insights.
3

Table Of Contents
Certificate . . . . . . . . . . . . . . . 1

Acknowledgement . . . . . . . . . . . . . 2

Introduction to Project . . . . . . . . . 4

Introduction to Python . . . . . . . . . 5

Coding . . . . . . . . . . . . . . . . . 6

Output . . . . . . . . . . . . . . . . . 8

Bibliography . . . . . . . . . . . . . . 10
4

Introduction To Project
"Introducing the Voice Assistant project, where we
utilized the power of Python and the OpenAI API to
create a cutting-edge virtual assistant. With this project,
users can interact with the assistant using natural
language commands to perform various tasks such as
setting reminders, playing music, and answering
questions. The integration of the OpenAI API allows for
advanced language processing capabilities, making the
Voice Assistant highly responsive and accurate. The
project was designed to be user-friendly, with a simple
and intuitive interface. Overall, this project demonstrates
the potential of combining Python and the OpenAI API to
create powerful, AI-driven applications."
5

Introduction To Python

Python is a popular, high-level programming language


known for its readability and simplicity. It is a versatile
language that can be used for a wide variety of tasks, from
web development and data analysis to artificial
intelligence and scientific computing. Some key features
of Python include its easy-to-learn syntax, its large and
active community, and the vast collection of libraries and
frameworks available for use. To get started with Python,
you will need a text editor or an integrated development
environment (IDE) to write and run your code. Some
popular options include IDLE (which comes pre-installed
with Python), PyCharm, and Visual Studio Code.
6

Coding
MAIN.PY :-

import openai
import pyttsx3
import speech_recognition as sr
from api_key import API_KEY

openai.api_key = API_KEY

engine = pyttsx3.init()

r = sr.Recognizer()
mic = sr.Microphone()

conversation = ""
user_name = "Jujhar"
bot_name = "Quartic"

while True:
with mic as source:
print("\nlistening...")
r.adjust_for_ambient_noise(source, duration=0.2)
audio = r.listen(source)
print("no longer listening.\n")

try:
user_input = r.recognize_google(audio)
except:
continue

prompt = user_name + ": " + user_input + "\n" + bot_name + ": "

conversation += prompt # allows for context

# fetch response from open AI api


7

response = openai.Completion.create(
engine='text-davinci-003', prompt=conversation, max_tokens=100)
response_str = response["choices"][0]["text"].replace("\n", "")
response_str = response_str.split(
user_name + ": ", 1)[0].split(bot_name + ": ", 1)[0]

conversation += response_str + "\n"


print(response_str)

engine.say(response_str)
engine.runAndWait()

api_key.py :-

API_KEY = "{Confidential}"

8

Output
9


10

Bibliography
1. GitHub. (2021). GitHub. Retrieved from https://github.com/

2. PyPI. (2021). PyPI - the Python Package Index. Retrieved from


https://pypi.org/

3. Microsoft. (2021). Visual Studio Code. Retrieved from


https://code.visualstudio.com/

4. OpenAI. (2021). OpenAI. Retrieved from https://openai.com/

5. OpenAI. (2021). GPT-3. Retrieved from https://openai.com/gpt-3/

You might also like