Hello to all learners and aspiring hackers around the globe. I have been following null byte for quite a long time and thought of posting my 1st article for programming .
Step 1: Python as a Guardian for Your Machine to Speak
python is language for hackers and coders and that's for sure.. i have been messing up with python and its really an interesting language to start as well as end with.Python generally popular cuz of the modules and library support that it provides,which makes it a very easy and powerful language. Without wasting time ,lets begin:-
Step 2: Do's Before Coding Your Own Jarvis in Python:-
1) First download and install python coding environment like :- enthought canopy or so , you can choose any dosnt matter.
2) import speech recognizer (pip install command)
3) import pyttsx
4) import pyaudio
5) import PocketSphinx
if some of them are present then make sure to update them
by pip install -U (command_name)
Step 3: The SOURCE CODE :-
import speech_recognition
import pyttsx
speech_engine = pyttsx.init('sapi5') # see http://pyttsx.readthedocs.org/en/latest/engine.html#pyttsx.init
speech_engine.setProperty('rate', (150))
def speak(text):
speech_engine.say(text)
speech_engine.runAndWait()
recognizer = speech_recognition.Recognizer()
def listen():
with speech_recognition.Microphone() as source:
recognizer.adjustforambient_noise(source)
audio = recognizer.listen(source)
try:
return recognizer.recognize_sphinx(audio)
# or: return recognizer.recognize_google(audio)
except speech_recognition.UnknownValueError:
print("Could not understand audio")
except speech_recognition.RequestError as e:
print("Recog Error; {0}".format(e))
return ""
eil=raw_input("type here:-")
speak(eil)
speak("i heard you say"+listen())
Step 4: POST- Coding Part:-
after having this in your python editor or text editor , save it as filename.py
and make sure to put a microphone on , to interact or atleast input command to program
after executing the program , you will be prompted to type here :-.. go on and write what you want to hear from your machine and then speak ... enjoy
am working on the same project and developing it with aiml (artificial intelligence markup language ) by using pyaiml to give response to human and be intelligent talker..
thanks guys !! do enjoy coding and hacking
Comments
No Comments Exist
Be the first, drop a comment!