initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import socket
|
||||
import sounddevice as sd
|
||||
import numpy as np
|
||||
|
||||
PORT = 50007
|
||||
SAMPLERATE = 44100
|
||||
CHANNELS = 1
|
||||
CHUNK = 1024
|
||||
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
sock.bind(('0.0.0.0', PORT))
|
||||
|
||||
def audio_callback(outdata, frames, time, status):
|
||||
data, _ = sock.recvfrom(CHUNK * 2) # 2 bytes per sample (int16)
|
||||
outdata[:] = np.frombuffer(data, dtype=np.int16).reshape(-1, CHANNELS)
|
||||
|
||||
with sd.OutputStream(samplerate=SAMPLERATE, channels=CHANNELS, dtype='int16', blocksize=CHUNK, callback=audio_callback):
|
||||
print("Receiving audio...")
|
||||
input() # Press Enter to stop
|
||||
Reference in New Issue
Block a user