diff --git a/assemblyai/extras.py b/assemblyai/extras.py index 7e844b3..5086b70 100644 --- a/assemblyai/extras.py +++ b/assemblyai/extras.py @@ -1,5 +1,5 @@ import time -from typing import BinaryIO, Generator +from typing import BinaryIO, Generator, Optional from warnings import warn from . import api @@ -22,17 +22,13 @@ def __init__( class MicrophoneStream: - def __init__( - self, - sample_rate: int = 44_100, - ): + def __init__(self, sample_rate: int = 44_100, device_index: Optional[int] = None): """ Creates a stream of audio from the microphone. Args: - chunk_size: The size of each chunk of audio to read from the microphone. - channels: The number of channels to record audio from. sample_rate: The sample rate to record audio at. + device_index: The index of the input device to use. If None, uses the default device. """ try: import pyaudio @@ -49,6 +45,7 @@ def __init__( rate=sample_rate, input=True, frames_per_buffer=self._chunk_size, + input_device_index=device_index, ) self._open = True