fork download
  1. import speech_recognition as sr
  2. import pyttsx3 as tts
  3. import sys,time
  4.  
  5. predkosc = 160
  6.  
  7. # LISTY GESTÓW
  8.  
  9. WYKRYJ = ["ziomeczek","ziomeczku","ziomuś"]
  10. DOWIEDZENIA = ["nara","narazie","nara ziom"]
  11.  
  12. def powitanie():
  13. print("")
  14. print("")
  15. print(" |\/\/\/|")
  16. print(" | |")
  17. print(" | (o)(o) NO SIEMA MORDECZKO")
  18. print(" C _) WZYWAŁEŚ MNIE")
  19. print(" | ___|")
  20. print(" | /")
  21. print("")
  22. print("")
  23.  
  24. r=sr.Recognizer()
  25. engine = tts.init()
  26. engine.setProperty('voice',engine.getProperty('voices')[0].id)
  27. engine.setProperty('rate', predkosc)
  28.  
  29. def speak(text):
  30. engine.say(text)
  31. engine.runAndWait()
  32.  
  33. def czy_zawiera(string,slowa):
  34. return [element for element in slowa if element in string.lower()]
  35.  
  36. def getText():
  37.  
  38. try:
  39. with sr.Microphone() as source:
  40. print("Nasłuchuję...", end="\r")
  41. audio = r.listen((source))
  42. text =r.recognize_google(audio, langue="pl-PL")
  43. if text == "":
  44. return None
  45. else:
  46. return text
  47. except:
  48. return None
  49.  
  50.  
  51. powitanie()
  52.  
  53. while True:
  54. time.sleep(0.5)
  55. cur = getText()
  56. print(""*50, end="\r")
  57. if cur != None:
  58. if len(czy_zawiera(cur,WYKRYJ)):
  59. if len(czy_zawiera(cur,DOWIEDZENIA)):
  60. speak("Żegnaj kotku")
  61. break
  62.  
Runtime error #stdin #stdout #stderr 0.16s 23460KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ModuleNotFoundError: No module named 'speech_recognition'