def fuzzydevices(match='', min_ratio=30): device_ratios = [] for device in devices(): 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 _findDevice(self): inputPriority = [ "FastTrack Pro", "Built-in Input", "Soundflower (2ch)", ] for input_ in inputPriority: for dev in pysoundcard.devices(): if dev['name'] == input_ and dev['input_channels'] > 0: return dev