Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- # -*- coding: utf-8 -*-
- import multiprocessing
- import speech_recognition as sr
- import time
- import pyaudio
- import json
- def microphone1():
- plik_tekstowy = open("TEXT.txt","r+")
- r = sr.Recognizer()
- with sr.Microphone() as source:
- text = ""
- while text == "":
- print("Yes?")
- audio = r.listen(source)
- try:
- text1 = r.recognize_google(audio)
- print("You say : {}".format(text1))
- plik_tekstowy.write(text1 + " ")
- plik_tekstowy.read().split()
- except:
- print("I don't understand")
- def microphone2():
- plik_tekstowy = open("/home/pi/Desktop/Rzeczy/TEXT.txt","w+")
- r = sr.Recognizer()
- with sr.Microphone() as source:
- text = ""
- while text == "":
- print("Yes?")
- audio = r.listen(source)
- try:
- text2 = r.recognize_google(audio)
- print("You say : {}".format(text2))
- plik_tekstowy.write(str(text2) + " ")
- except:
- print("I don't understand")
- def microphone3():
- plik_tekstowy = open("/home/pi/Desktop/Rzeczy/TEXT.txt","w+")
- r = sr.Recognizer()
- with sr.Microphone() as source:
- text = ""
- while text == "":
- print("Yes?")
- audio = r.listen(source)
- try:
- text3 = r.recognize_google(audio)
- print("You say : {}".format(text3))
- plik_tekstowy.write(str(text3) + " ")
- except:
- print("I don't understand")
- def multi_microphones():
- pr1 = multiprocessing.Process(target=microphone1)
- pr2 = multiprocessing.Process(target=microphone2)
- pr3 = multiprocessing.Process(target=microphone3)
- pr1.start()
- pr2.start()
- pr3.start()
- pr1.join()
- pr2.join()
- pr3.join()
- text= open('TEXT.txt','r+').read().split()
- print(text)
- return text
- while True:
- x= multi_microphones()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement