Controlling volume from speakers

You could use a digital pot to controle the volume of a sound signal:-

Or do you want to generate the sound as well?