If you have SoX, you can write your encoded data to a binary file, and play it back using a bunch of command line options to tell SoX the correct format. I think you can do:
$ sox --bits 8 --channels 1 --encoding mu-law --rate 8000 file.raw --default-device
It always takes me a couple of tries to get the options right, but it's a useful utility for dealing with audio data. The command line should be the same across OSes. If the --default-device
option doesn't correctly work for you, you can specify an output WAV (or whatever) file instead.
Note the extension of the file is important. SoX will use the extension to try and predict some of the channel/bitwdith/sample rate parameters. sox -h
will show you the full list of recognized file types.