@@ -403,35 +403,15 @@ def _input_callback(
403403 channels_arg = 1
404404 mapping = [int (input_channel_index ) + 1 ]
405405
406- # Build kwargs and conditionally include 'mapping' based on sounddevice version
407- stream_kwargs : dict [str , Any ] = {
408- "callback" : _input_callback ,
409- "dtype" : "int16" ,
410- "channels" : channels_arg ,
411- "device" : input_device ,
412- "samplerate" : self ._in_sr ,
413- "blocksize" : self ._blocksize ,
414- }
415- try :
416- init_params = inspect .signature (sd .InputStream .__init__ ).parameters
417- if "mapping" in init_params and mapping is not None :
418- stream_kwargs ["mapping" ] = mapping
419- elif mapping is not None :
420- logging .getLogger (__name__ ).warning (
421- "sounddevice.InputStream does not support 'mapping' in this version; "
422- "ignoring input_channel_index=%s" ,
423- input_channel_index ,
424- )
425- except Exception :
426- # If inspection fails for any reason, fall back without mapping
427- if mapping is not None :
428- logging .getLogger (__name__ ).warning (
429- "Unable to inspect sounddevice.InputStream.__init__; "
430- "ignoring input_channel_index=%s" ,
431- input_channel_index ,
432- )
433-
434- input_stream = sd .InputStream (** stream_kwargs )
406+ input_stream = sd .InputStream (
407+ callback = _input_callback ,
408+ dtype = "int16" ,
409+ channels = channels_arg ,
410+ device = input_device ,
411+ samplerate = self ._in_sr ,
412+ blocksize = self ._blocksize ,
413+ mapping = mapping ,
414+ )
435415 input_stream .start ()
436416
437417 async def _pump () -> None :
0 commit comments