pub(crate) fn input_config(device: &Device) -> Result<InputPlan, Error>Expand description
Pick an input the models can read.
A device offering SAMPLE_RATE opens natively, fewest channels winning:
less to average, less to go wrong. F32 is preferred at equal channels
because it skips the conversion, but I16 is taken where that is all the
device has. One that cannot serve the model rate still opens its best
config - fewest channels, then the rate nearest the model rate - and its
audio is downmixed and resampled with a real filter downstream. Measured
on the target hardware, which offers 16, 24 and 32 kHz and never fewer
than two channels - so requiring mono here would have meant no microphone
at all - and on USB microphones that offer only 48 kHz.
What is still refused is a device offering neither F32 nor I16: the error names the formats the capture takes, then everything the device offered, so the mismatch is legible as the format it is.