White Paper

Tuberculosis Screening Using Cough Sounds

A machine learning system that screens for tuberculosis by analyzing cough sound recordings, achieving 97% accuracy with a CNN deployed as a real-time web application.

Technology AI
Technology Category
Jun 2025 Published
Ganeshan K Lead author

Overview

An innovative solution for the early detection of tuberculosis (TB) using machine learning is introduced, specifically through the analysis of cough sound recordings. TB remains a leading cause of death worldwide[1], and early diagnosis is crucial to preventing its spread. Traditional TB screening methods are often costly, complex, and unavailable in resource-limited settings, leading to delayed diagnoses and increased transmission.

To address this challenge, a machine learning-based system was developed to analyze cough sound samples and detect the likelihood of TB. The system leverages Convolutional Neural Networks (CNN) for accurate classification, achieving an impressive 97% accuracy on the TBScreen dataset. The primary feature of this solution is its simplicity and accessibility, enabling real-time TB detection through a user-friendly web application[2].

The web application, built using Flask and hosted on Firebase, allows users to upload cough sound recordings and receive instant feedback on whether they are likely to have TB. This integration provides a non-invasive, low-cost, and scalable alternative to traditional diagnostic methods, especially valuable in regions with limited healthcare infrastructure. The key components of the system, from data preprocessing and model development to the web application’s deployment, are outlined. The potential of this solution to address significant healthcare gaps is highlighted by facilitating early TB diagnosis in a cost-effective manner. Future directions include model refinement and dataset expansion, aimed at enhancing its reach and impact globally. The integration of machine learning and web technologies in this project represents a promising step forward in the global effort to combat tuberculosis and improve public health outcomes worldwide.

Introduction

Tuberculosis is one of the most contagious infectious diseases, claiming millions of lives annually, especially in low-income countries. Early diagnosis is crucial, as untreated TB can lead to severe health complications and transmission to others. Traditional diagnostic methods for TB, such as chest X-rays, sputum smear tests[3], and molecular assays, are highly effective but require substantial resources, infrastructure, and trained personnel. These requirements make them unsuitable for large-scale or remote TB screening.

Line chart titled Global trend in case notifications of people newly diagnosed with TB, 2010 to 2022. Notifications per year rise from about 5.8 million in 2010 to roughly 7.1 million in 2019, drop sharply to about 5.8 million in 2020, then climb to about 7.4 million by 2022.
Global trend in TB case notifications, 2010–2022. Source: World Health Organization, Global Tuberculosis Report.

Advances in machine learning and signal processing offer a new path for TB detection. Research has shown that human respiratory sounds[4], such as breath and cough sounds, carry distinct features that correlate with lung abnormalities. Acoustic signal analysis, combined with artificial intelligence (AI)[5], could provide a non-invasive and cost-effective solution for TB screening. This paper explores this innovative approach using cough sounds.

Despite the availability of TB diagnostic tests, barriers like high costs, lack of accessibility, and delayed diagnoses hinder effective disease control, especially in areas with limited healthcare access. The gap between symptom onset and diagnosis, particularly for underserved populations, further exacerbates TB transmission. This highlights the need for a cheaper, faster, and more scalable diagnostic tool.

Problem Statement

TB is often diagnosed at a late stage due to the lack of widespread screening, and patients typically present with symptoms like persistent cough, chest pain, and weight loss. In many low-resource settings, access to healthcare facilities is limited, resulting in delayed diagnosis and treatment, contributing to the ongoing spread of the disease.

Line chart titled Global success rates for people treated for TB, 2012 to 2021. People newly diagnosed with TB and enrolled on first-line treatment hold a success rate of roughly 85 percent throughout the period. People diagnosed with MDR or RR-TB and enrolled on an MDR/RR-TB treatment regimen rise from about 50 percent in 2012 to about 63 percent in 2020. A footnote notes that 2012 is the first year for which WHO collected data about treatment outcomes for MDR/RR-TB.
Global TB treatment success rates, 2012–2021. Source: World Health Organization, Global Tuberculosis Report.

Traditional TB detection methods[6], though effective, have limitations. They require specialized laboratory facilities, trained healthcare workers, and are often unavailable in remote or underserved areas. Additionally, they are costly and time-consuming. Early detection is vital, and there is a pressing need for a diagnostic tool that is cost-effective, easy to deploy, and can be used for mass screening. Using cough sounds as a diagnostic signal could revolutionize TB screening by enabling simple, fast, and inexpensive tests.

The primary goal of this study is to evaluate the effectiveness of machine learning algorithms in detecting tuberculosis (TB) by analyzing the acoustic characteristics of cough sounds. This research specifically tests a Convolutional Neural Network (CNN) model using features extracted from cough sounds and compares its performance to traditional TB detection methods.

Methodology

Block diagram of the TB screening pipeline: audio, sampled audio, MFCC feature extraction, neural network, then classification as asymptomatic or symptomatic.
Block diagram
  • Dataset Description: The TB Screen dataset[7] consists of cough sound recordings from individuals with TB and healthy subjects. The dataset includes labeled audio samples of one second durations.
  • Data Preprocessing: The dataset contains Passive and Forced cough sounds preprocessed separately. The dataset contains unwanted audio samples like no cough sounds and they are removed.
  • Feature Extraction: Mel-frequency cepstral coefficients (MFCC) were extracted from the preprocessed cough sound signals. MFCCs are widely used in speech and audio processing because they capture the essential characteristics of sound. The extracted MFCCs were used as features for model input.
  • Convolutional Neural Network: A Convolutional Neural Network (CNN) model is used for TB detection from cough sounds. The input features are extracted using Mel-Frequency Cepstral Coefficients (MFCC). The model is trained with an 80:20 ratio of training to validation datasets.

Model Results

The Convolutional Neural Network (CNN) model achieved an impressive 97% accuracy on the TBScreen dataset, consisting of 4,399 cough sound samples. The model demonstrated strong performance in classifying Symptomatic and Asymptomatic, with minimal overfitting.

Confusion matrix for the training dataset: 1,697 healthy samples predicted healthy and 1 predicted TB; 4 TB samples predicted healthy and 1,817 predicted TB.
Confusion matrix of train dataset

The training and validation accuracy curves show a consistent increase in accuracy over time, indicating effective learning. Similarly, the loss curves show a steady decrease in both training and validation loss, confirming the model’s ability to generalize well. These results highlight the potential of the CNN-based approach for accurate and efficient TB detection from cough sounds, making it a promising tool for early diagnosis, especially in resource-limited settings.

Two line charts across about 18 training epochs. Model accuracy rises from roughly 0.70 to about 0.97 for both training and validation; model loss falls from roughly 0.5 to about 0.1 for both.
Accuracy and loss curve between train and validation

Web Application Integration

A person seated at a desk using the TB screening web application on a desktop monitor, with the upload form and the application's lung-and-waveform branding visible on screen.

The integration of the tuberculosis (TB) detection model into a web application allows users to interact with the system and receive real-time TB diagnosis based on their cough sound recordings. The system is built using Flask, a lightweight Python web framework, and deployed on Firebase, which provides a scalable and accessible platform for hosting the application.

The web application is designed to be user-friendly and accessible, requiring only a simple audio file upload from users to initiate the TB detection process. The uploaded cough sound file is processed by the trained Convolutional Neural Network (CNN) model. In the backend, the audio file extracts key features, which the model uses to predict and output results as either Symptomatic or Asymptomatic. This analysis allows the system to determine whether the user is likely to have tuberculosis.

The integration of this machine learning model into the web application enables fast, accurate, and non-invasive TB screening. The system is designed to be a cost-effective and efficient alternative for TB detection, especially in low-resource areas.

The implemented web application: https://nkorr-tb-detect.web.app/

Two result cards from the web application. One reads Test Result Symptomatic with accuracy 99.9; the other reads Test Result Asymptomatic with accuracy 100. Both carry a notice that the software is not intended to diagnose, cure, mitigate, treat or prevent diseases.

Conclusion

This study demonstrates the use of machine learning, specifically Convolutional Neural Networks (CNN), for the accurate detection of tuberculosis (TB) through cough sound analysis, achieving 97% accuracy on the TB Screen dataset. By integrating the model into a Flask-based web application, we provide a user-friendly, low-cost solution for real-time TB screening. This web app allows users to upload cough sound recordings and receive immediate results, making it an accessible tool for early TB detection, particularly in resource-limited areas. While the model shows strong performance, future improvements could focus on expanding the dataset, refining the model’s generalization, and developing a mobile version of the app for broader deployment. Overall, this approach offers a promising, scalable solution for improving TB diagnosis and reducing its spread globally.

Read the original white paper This page carries the full content of the paper. Download the PDF for the original typeset version.
Download PDF

Authors & Contributors

Ganeshan K Ganeshan K Software Engineer
Vishak Kurup Vishak Kurup Technical Architect

References

  1. World Health Organization — Tuberculosis — who.int/health-topics/tuberculosis. The two global TB trend charts above are reproduced from the WHO Global Tuberculosis Report — who.int/teams/global-programme-on-tuberculosis-and-lung-health/tb-reports
  2. Deployed application — nkorr-tb-detect.web.app
  3. Sputum smear reference dataset — zenodo.org/records/10431329
  4. Liao S., Song C., Wang X., Wang Y., “A classification framework for identifying bronchitis and pneumonia in children based on a small-scale cough sounds dataset,” PLOS ONE, 2022; 17: e0275479. PMID 36301797.
  5. Balamurali B.T. et al., “Deep Neural Network-Based Respiratory Pathology Classification Using Cough Sounds,” Sensors, 2021 — doi.org/10.3390/s21165555
  6. Devasia J., Goswami H., Lakshminarayanan S., Rajaram M., Adithan S., “Deep learning classification of active tuberculosis lung zones wise manifestations using chest X-rays: a multi label approach,” Scientific Reports, 2023; 13(1): 887 — doi.org/10.1038/s41598-023-28079-0
  7. Sharma et al., “TBscreen: A Passive Cough Classifier for Tuberculosis Screening with a Controlled Dataset,” Science Advances, 2024.

Work with us

Building AI-assisted
screening for your care setting?

Tell us about your project. We'll tell you honestly whether and how we can help.