@Euromir The tone function will do that. I have used it in this project to register when the touch buttons are pressed. I have used a small piezo buzzer but i believe a speaker can also be used.
It is very easy to use, just three parameters pinnumber,frequency,duration
So to play a tone on pin 7 at 1200Hz for 60ms you would use
tone(7, 1200, 60);