Of course pressure and temperature play a role. Sound propagates as a mechanical wave with molecules hitting their neighbours. The more dense the medium, the closer the neighbours...
I may add that the speed of sound depends also on the type of wave, i.e., longitudinal waves, bending waves, shear waves, etc. In fluids, only longitudinal waves are considered and then the speed of sound depends upon some physical characteristics of the fluid, density, temperature, atmospheric pressure, etc. In solids, the phenomena is more complicated and you must include additional physical properties for the solid medium (Young's modulus, density, Poisson's ratio, etc.). The book on Acoustics by A. Pierce is a very good source of information about this topic.