Advertisement
Guest User

Untitled

a guest
Jan 14th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import os
  2. import speech_recognition as sr
  3. from pexpect import pxssh
  4.  
  5. # Add more commands and their respective speeches here.
  6. 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'}
  7. cmd = None
  8. alias = None
  9.  
  10. # Enter Remote host credentials
  11. hostname = raw_input("Hostname: ")
  12. username = raw_input("Username: ")
  13. password = raw_input("Password: ")
  14. s = pxssh.pxssh()
  15.  
  16. try:
  17. s.login(hostname, username, password)
  18.  
  19. except pxssh.ExceptionPxssh as e:
  20. print("Can't connect to ssh: " + e)
  21. r = sr.Recognizer()
  22. with sr.Microphone() as source:
  23. r.adjust_for_ambient_noise(source)
  24. print("Say something!")
  25. audio = r.listen(source)
  26. print("Recognizing audio")
  27. try:
  28. alias = r.recognize_google(audio)
  29. except:
  30. print("Unable to recognize audio")
  31.  
  32.  
  33. for i in dic:
  34. if i==alias:
  35. s.sendline(dic[i])
  36. s.prompt()
  37. print(s.before)
  38. s.logout()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement