How to specify the audio format for recording?

I would like to record audio for a telephony application in 8kHz, uLaw codec but I do not see any method to specify the audio recording format for the record() function (sampling rate, channels, sample bit size, codec)
Is that possible or I need to postprocess the recording?