Как воспроизводить текущий звук с колонки в python

Примерно как 'то только не микрофон, а динамики:

import pyaudio
import numpy as np
import time

p = pyaudio.PyAudio()

CHANNELS = 2
RATE = 44100

def callback(in_data, frame_count, time_info, flag):
    return in_data, pyaudio.paContinue

stream = p.open(format=pyaudio.paFloat32,
                channels=CHANNELS,
                rate=RATE,
                output=True,
                input=True,
                stream_callback=callback)

stream.start_stream()

while stream.is_active():
    time.sleep(4)
    stream.stop_stream()
    print("Stream is stopped")

stream.close()

p.terminate()

Ответы (0 шт):