When I execute my code in a specific physical location an error occurs (sounddevice library)

89 Views Asked by At

I have a code for handle audio data through a sound device library. My code works perfectly, but when I execute my code in a specific physical location an error occurs. Crucially, if I move elsewhere, the problem is solved.

import time
import sounddevice as sd

class Test:
    def __init__(self):
        self.block_shift = 128  # audio block shift
        self.block_len = 512  # audio block length
        self.sampling_rate = 16000  # sampling rate
        self.sound_device_latency = 'low'  # latency of callback

    def Start(self, input_device_index, output_device_index):
        with sd.Stream(device=(input_device_index, output_device_index),latency=self.sound_device_latency,
                   channels=1, callback=self.callback) as stream_object:
            while stream_object.active:
                time.sleep(0.1)

    def callback(self, indata, outdata, frames, time, status):
        if status:
            print(status)

        #print(indata)
        outdata[:] = indata


Test().Start(2, 3)

I used the method officially recommended by sounddevice.

When I execute my code in my office, the input data (indata) passed from the microphone becomes [0.]. But there is no problem in cafes, restaurants or my house.

When I print indata and status in the callback, it is as follows:

input overflow, output underflow (status)
[0.] (indata)
[0.] (indata)
[0.] (indata)
...
input overflow, output underflow (status)
[0.] (indata)
[0.] (indata)
[0.] (indata)
...
input overflow, output underflow (status)

My computer's CPU and memory are fine.

1

There are 1 best solutions below

3
On

It's mostly a security policy applied in your office network.