ZOHO Ai Vioce Assistant
Voice Assistant ( Zoho Ai Vioce Assistant )
As we know Python is a suitable language for scriptwriters and developers. Let’s write a script for Voice Assistant using Python. The query for the assistant can be manipulated as per the user’s need.
Speech recognition is the process of converting audio into text. This is commonly used in voice assistants like Alexa, Siri, etc. Python provides an API called SpeechRecognition to allow us to convert audio into text for further processing. In this article, we will look at converting large or long audio files into text using the SpeechRecognition API in python.
( import
subprocess
import
wolframalpha
import
pyttsx3
import
tkinter
import
json
import
random
import
operator
import
speech_recognition as sr
import
datetime
import
wikipedia
import
webbrowser
import
os
import
winshell
import
pyjokes
import
feedparser
import
smtplib
import
ctypes
import
time
import
requests
import
shutil
from
twilio.rest
import
Client
from
clint.textui
import
progress
from
ecapture
import
ecapture as ec
from
bs4
import
BeautifulSoup
import
win32com.client as wincl
from
urllib.request
import
urlopen )
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def
speak(audio):
engine.say(audio)
engine.runAndWait()
def
wishMe():
hour
=
int
(datetime.datetime.now().hour)
if
hour>
=
0
and
hour<
12
:
speak(
"Good Morning Sir !"
)
elif
hour>
=
12
and
hour<
18
:
speak(
"Good Afternoon Sir !"
)
else
:
speak(
"Good Evening Sir !"
)
assname
=
(
"Jarvis 1 point o"
)
speak(
"I am your Assistant"
)
speak(assname)
def
username():
speak(
"What should i call you sir"
)
uname
=
takeCommand()
speak(
"Welcome Mister"
)
speak(uname)
columns
=
shutil.get_terminal_size().columns
print
(
"#####################"
.center(columns))
print
(
"Welcome Mr."
, uname.center(columns))
print
(
"#####################"
.center(columns))
speak(
"How can i Help you, Sir"
)
def
takeCommand():
r
=
sr.Recognizer()
with sr.Microphone() as source:
print
(
"Listening..."
)
r.pause_threshold
=
1
audio
=
r.listen(source)
try
:
print
(
"Recognizing..."
)
query
=
r.recognize_google(audio, language
=
'en-in'
)
print
(f
"User said: {query}\n"
)
except
Exception as e:
print
(e)
print
(
"Unable to Recognize your voice."
)
return
"None"
return
query
def
sendEmail(to, content):
server
=
smtplib.SMTP(
'smtp.gmail.com'
,
587
)
server.ehlo()
server.starttls()
# Enable low security in gmail
server.login(
'your email id'
,
'your email password'
)
server.sendmail(
'your email id'
, to, content)
server.close()
( https://www.geeksforgeeks.org/voice-assistant-using-python/amp/)https://www.geeksforgeeks.org/voice-assistant-using-python/amp/
Just trial
ReplyDelete