Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import speech_recognition as sr
- from pexpect import pxssh
- # Add more commands and their respective speeches here.
- dic={'list' : 'ls','present working directory' : 'pwd', 'open calender' : 'cal', 'light off' : 'python OffLight.py', 'blue' : 'python OnBlue.py', 'light on' : 'python OnRed.py', 'green' : 'python OnGreen.py'}
- cmd = None
- alias = None
- # Enter Remote host credentials
- hostname = raw_input("Hostname: ")
- username = raw_input("Username: ")
- password = raw_input("Password: ")
- s = pxssh.pxssh()
- try:
- s.login(hostname, username, password)
- except pxssh.ExceptionPxssh as e:
- print("Can't connect to ssh: " + e)
- r = sr.Recognizer()
- with sr.Microphone() as source:
- r.adjust_for_ambient_noise(source)
- print("Say something!")
- audio = r.listen(source)
- print("Recognizing audio")
- try:
- alias = r.recognize_google(audio)
- except:
- print("Unable to recognize audio")
- for i in dic:
- if i==alias:
- s.sendline(dic[i])
- s.prompt()
- print(s.before)
- s.logout()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement