This is a classical example of Supervised Machine Learning, where data scientist provide sound files to train the AI. Typically data scientist will have 2 sets of sound files.
1) Sound files that people have respiratory diseases and tag it as "unhealthy"
2) Sound files that people have healthy lungs and tag it as "healthy"
When the sample size is big enough, AI will identify a pattern to distinguish healthy lungs from "unhealthy" ones. When AI listen to a new patient's lung, AI will compare this new voice file with the previously identified pattern and predict whether this new patient is "healthy" or "unhealthy". Doctors can then follow up with the patient.
AI will never be 100% accurate. Neither can a doctor be 100% correct on diagnosis. It is arguable that AI is more accurate in some cases. The bigger the sample size (more training sound files), the more accurate the AI model will be.