19 lines
522 B
Python
19 lines
522 B
Python
import socket
|
|
import sounddevice as sd
|
|
import numpy as np
|
|
|
|
# Settings
|
|
IP = '10.42.0.231' # when rpi is connected to the ethernet socket of the laptop
|
|
PORT = 50007
|
|
SAMPLERATE = 44100
|
|
CHANNELS = 1
|
|
CHUNK = 1024
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
|
|
def callback(indata, frames, time, status):
|
|
sock.sendto(indata.tobytes(), (IP, PORT))
|
|
|
|
with sd.InputStream(samplerate=SAMPLERATE, channels=CHANNELS, blocksize=CHUNK, callback=callback):
|
|
print("Streaming audio...")
|
|
input() # Press Enter to stop |