Reliable quantification of pulmonary arterial pressure is essential in the diagnostic and prognostic assessment of a range of cardiovascular pathologies including rheumatic heart disease, yet an accurate and routinely available method for its quantification remains elusive. This work proposes an approach to infer pulmonary arterial pressure based on scientific machine learning techniques and non-invasive, clinically available measurements. A 0-D multicompartment model of the cardiovascular system was optimized using several optimization algorithms, subject to forward-mode automatic differentiation. Measurement data were synthesized from known parameters to represent the healthy, mitral regurgitant, aortic stenosed and combined valvular disease situations with and without pulmonary hypertension. Eleven model parameters were selected for optimization based on 95 % explained variation in mean pulmonary arterial pressure. A hybrid Adam and limited-memory Broyden-Fletcher-Goldfarb-Shanno optimizer yielded the best results with input data including valvular flow rates, heart chamber volume changes and systematic arterial pressure. Mean absolute percentage errors ranged from 1.8 % to 3.78 % over the simulated test cases. The model was able to capture pressure dynamics under hypertensive conditions with pulmonary arterial systole, diastole, and mean pressure average percentage errors of 1.12 %, 2.49 % and 2.14 %, respectively. The relatively low errors highlight the potential of the proposed model to recover pulmonary pressures for diseased heart valve and pulmonary hypertensive conditions.