bastibe / SoundCard

A Pure-Python Real-Time Audio Library
https://soundcard.readthedocs.io
BSD 3-Clause "New" or "Revised" License
680 stars 69 forks source link

How to stop streaming? #35

Closed jundengdeng closed 4 years ago

jundengdeng commented 5 years ago

Hi Bastibe

First of all, thanks a lot for sharing this project.

In pyaduio, there is a way to start or stop streaming. Here, I'd like to know if there is a way to allow an Microphone object to explicitly exit the real-time streaming.

The example code is like the following:

import soundcard as sc
import numpy

# get the current default microphone on your system:
default_mic = sc.default_microphone()
data = default_mic.record(samplerate=48000, numframes=48000)
# Can I stop streaming?

Thanks for your time!

Jun

bastibe commented 5 years ago

The record method will stop automatically once numframes samples have been recorded. Use the recorder context manager to record continuously.