I'm not sure I am following what you are saying.
Incidentally, your syntax for the sound test pasted above is incorrect, it should be:
speaker-test -c2 -t wav
which is quite possibly why you got the output you got then. The script should work without sudo in any case (and runs this exact test). Well, it does elevate privilieges as needed for steps where that is necessary.