Created
March 22, 2016 04:48
-
-
Save anonymous/01d0e1888bf282cdf477 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def audio_send_data(self): | |
'''records the audio data and sends it across to the clients''' | |
pyaudio_obj=pyaudio.PyAudio() | |
#record | |
CHUNK = 1024 | |
FORMAT = pyaudio.paInt16 | |
CHANNELS = 1 | |
RATE = 44100 | |
RECORD_SECONDS = 40 | |
stream=pyaudio_obj.open(format=FORMAT,channels=CHANNELS,rate=RATE,input=True, | |
frames_per_buffer=CHUNK) | |
while True: | |
audio_data = stream.write(CHUNK) | |
for client in self.clients_audio: | |
try: | |
client.send(audio_data) | |
except socket.error as e: # if no socket if connected | |
traceback.print_exc() | |
stream.stop_stream() | |
stream.close() | |
pyaudio_obj.terminate() | |
self.sock_audio.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment