def fuzzydevices(match='', min_ratio=30): device_ratios = [] for device in device_info(): ratio = fuzz.partial_ratio(match, device['name']) if ratio > min_ratio: device_ratios.append((ratio, device)) for ratio, device in sorted(device_ratios, key=lambda ratio_device: (ratio_device[0])): yield device
def getDevices(kind=None): """Returns a dict of dict of audio devices of sepcified `kind` The dict keys are names and items are dicts of properties """ devs = {} for ii, dev in enumerate(soundcard.device_info()): if (dev['max_output_channels']==0 and kind=='output' or dev['max_input_channels']==0 and kind=='input'): continue devs[dev['name']] = dev dev['id'] = ii return devs
def getDevices(kind=None): """Returns a dict of dict of audio devices of sepcified `kind` The dict keys are names and items are dicts of properties """ devs = {} for ii, dev in enumerate(soundcard.device_info()): if (dev['max_output_channels'] == 0 and kind == 'output' or dev['max_input_channels'] == 0 and kind == 'input'): continue devs[dev['name']] = dev dev['id'] = ii return devs
def getDevices(kind=None): """Returns a dict of dict of audio devices of specified `kind` The dict keys are names and items are dicts of properties """ devs = {} for ii, dev in enumerate(soundcard.device_info()): if (dev['max_output_channels']==0 and kind=='output' or dev['max_input_channels']==0 and kind=='input'): continue # newline characters must be removed devName = dev['name'].replace('\r\n','') devs[devName] = dev dev['id'] = ii return devs