The identification of the exact positions of the first and second heart sounds within a phonocardiogram (PCG), or heart sound segmentation, is an essential step in the automatic analysis of heart sound recordings, allowing for the classification of pathological events. While threshold-based segmentation methods have shown modest success, probabilistic models, such as hidden Markov models, have recently been shown to surpass the capabilities of previous methods. Segmentation performance is further improved when a priori information about the expected duration of the states is incorporated into the model, such as in a hidden semi-Markov model (HSMM). This article addresses the problem of the accurate segmentation of the first and second heart sound within noisy, real-world PCG recordings using a HSMM, extended with the use of logistic regression for emission probability estimation. In addition, we implement a modified Viterbi algorithm for decoding the most-likely sequence of states, and evaluated this method on a large dataset of 10172 seconds of PCG recorded from 112 patients (including 12181 first and 11627 second heart sounds). The proposed method achieved an average F1 score of 95.630.85% while the current state-ofthe- art achieved 86.281.55% when evaluated on unseen test recordings. The greater discrimination between states afforded using logistic regression as opposed to the previous Gaussian distribution-based emission probability estimation as well as the use of an extended Viterbi algorithm allows this method to significantly outperform the current state-of-the-art method based on a two-sided, paired t-test.