File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -25,14 +25,14 @@ class MicrophoneStream:
2525 def __init__ (
2626 self ,
2727 sample_rate : int = 44_100 ,
28+ device_index : int = None
2829 ):
2930 """
3031 Creates a stream of audio from the microphone.
3132
3233 Args:
33- chunk_size: The size of each chunk of audio to read from the microphone.
34- channels: The number of channels to record audio from.
3534 sample_rate: The sample rate to record audio at.
35+ device_index: The index of the input device to use. If None, uses the default device.
3636 """
3737 try :
3838 import pyaudio
@@ -49,6 +49,7 @@ def __init__(
4949 rate = sample_rate ,
5050 input = True ,
5151 frames_per_buffer = self ._chunk_size ,
52+ input_device_index = device_index ,
5253 )
5354
5455 self ._open = True
@@ -143,4 +144,4 @@ def file_from_stream(data: BinaryIO) -> str:
143144 return api .upload_file (
144145 client = Client .get_default ().http_client ,
145146 audio_file = data ,
146- )
147+ )
You can’t perform that action at this time.
0 commit comments