Continuous monitoring of pig behavior is essential for timely health management and welfare assessment in commercial production systems. Although vision-based methods have been widely studied, their practical application in commercial barns is often limited by variable lighting, frequent occlusion, and high stocking density. Acoustic sensing offers a non-contact alternative that is independent of lighting conditions; however, reliable behavior classification from pig vocalizations remains challenging in commercial environments because of background noise and temporal variability in sound patterns. In this study, an attention-guided acoustic framework, termed ATF-Conformer, was developed for pig vocalization classification under farm conditions. A five-class vocalization dataset was collected from finishing Landrace pigs and multiparous sows on a commercial farm, including cough, scream, estrus, feeding, and normal behavior sounds. The proposed framework combined spectrogram denoising with interactive attention to enhance behavior-related acoustic information, while a time-frequency-decoupled Conformer encoder was introduced to improve feature representation under noisy conditions. Final classification was performed using mask-based temporal pooling with an additive angular margin Softmax objective. In five-fold grouped cross-validation, ATF-Conformer achieved an accuracy of 97.34% ± 0.42 and outperformed several existing acoustic models across multiple evaluation metrics. A similar accuracy of 97.38% was obtained on an independent test set, indicating stable performance across datasets. These results suggest that the proposed method can support continuous, non-invasive pig vocalization-based behavior monitoring and may assist farm owners or workers in pen-level screening of frequent cough or abnormal vocal events, thereby supporting targeted on-site inspection in precision livestock farming.
Wang et al. (Mon,) studied this question.