Objective: To design an AI-powered tool to automatically assess the quality of phonocardiogram (PCG) recordings, and then identify S1 and S2 heart sounds using PCG recordings only. Methods We used PCG recordings from two datasets; a publicly available dataset (the 2016 PhysioNet/CinC Challenge), and a dataset that we collected as part of a clinical study we are conducting at Oregon Health Science University (OHSU). We developed a logistic regression classifier to score PCG signal quality using semi-supervised learning and a two-layer perceptron artificial neural network classifier with con textual time-and frequency-domain input features to detect fundamental S1 and S2 heart sounds. We also analyzed the impact of input features on the accuracy of S1 and S2 segmentation. Results: Our segmentation method detects fundamental S1 and S2 heart sounds with a precision of 93% and distinguishes S1/S2 heart sounds with area under the curve (AUC) of 97.1%. Conclusions: Implementing a signal quality assessment tool allows for better segmentation performance as only suitable signals are processed by the S1/S2 sound detection and classification algorithms. Distance between sounds in time-domain are able to distinguish between S1 and S2 with accuracy of 87.4%; however, by adding the frequency-domain features, the accuracy significantly improved to 9 2.4%. Significance: S1 an d S2 heart sound segmentation is the first step in the processes of detecting and classifying heart abnormalities from a PCG. Our proposed method is simple and effective for segmentation for this task. Consequently, it can facilitate the performance of subsequent tasks including the detection of heart murmurs.