0

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.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578

1 Answers1

0

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

Ahmed
  • 25
  • 8
  • Do you mean wave interference or aliasing frequency? – freshcodeman Apr 21 '21 at 07:03
  • No, Not at all .. in some work places, the security team apply policies to avoid potential risks such as blocking some sites or preventing using USB drives .. can this be the case with your microphone? – Ahmed Apr 21 '21 at 07:08
  • No, I'm using a built-in microphone on my laptop. And I'm the owner of the office, and I didn't apply a security policy. – freshcodeman Apr 21 '21 at 07:12