Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. #! /usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. import multiprocessing
  4. import speech_recognition as sr
  5. import time
  6. import pyaudio
  7. import json
  8. def microphone1():
  9. plik_tekstowy = open("TEXT.txt","r+")
  10. r = sr.Recognizer()
  11. with sr.Microphone() as source:
  12. text = ""
  13. while text == "":
  14. print("Yes?")
  15. audio = r.listen(source)
  16. try:
  17. text1 = r.recognize_google(audio)
  18. print("You say : {}".format(text1))
  19. plik_tekstowy.write(text1 + " ")
  20. plik_tekstowy.read().split()
  21. except:
  22. print("I don't understand")
  23. def microphone2():
  24. plik_tekstowy = open("/home/pi/Desktop/Rzeczy/TEXT.txt","w+")
  25. r = sr.Recognizer()
  26. with sr.Microphone() as source:
  27. text = ""
  28. while text == "":
  29. print("Yes?")
  30. audio = r.listen(source)
  31. try:
  32. text2 = r.recognize_google(audio)
  33. print("You say : {}".format(text2))
  34. plik_tekstowy.write(str(text2) + " ")
  35. except:
  36. print("I don't understand")
  37. def microphone3():
  38. plik_tekstowy = open("/home/pi/Desktop/Rzeczy/TEXT.txt","w+")
  39. r = sr.Recognizer()
  40. with sr.Microphone() as source:
  41. text = ""
  42. while text == "":
  43. print("Yes?")
  44. audio = r.listen(source)
  45. try:
  46. text3 = r.recognize_google(audio)
  47. print("You say : {}".format(text3))
  48. plik_tekstowy.write(str(text3) + " ")
  49. except:
  50. print("I don't understand")
  51. def multi_microphones():
  52. pr1 = multiprocessing.Process(target=microphone1)
  53. pr2 = multiprocessing.Process(target=microphone2)
  54. pr3 = multiprocessing.Process(target=microphone3)
  55. pr1.start()
  56. pr2.start()
  57. pr3.start()
  58. pr1.join()
  59. pr2.join()
  60. pr3.join()
  61. text= open('TEXT.txt','r+').read().split()
  62. print(text)
  63. return text
  64.  
  65.  
  66. while True:
  67. x= multi_microphones()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement