import pyaudio
import numpy as np
import time
RATE=44100
pa = pyaudio.PyAudio()
stream = pa.open(format=pyaudio.paFloat32,
channels=1,
rate=RATE,
output=True)
t = time.time()
output = np.ones(44100)*100
stream.write(output)
print(time.time()-t)
This is a test code. With 44100 sample rate, when playing 44100 samples, the time cost should be 1s. However, the output is not. Why does it happen? I am looking forward to someone's answer. Thank you very much.