Looking at the code it makes reference to ATMega pins OC2A and OC2B, the Arduino Atmega pin mapping diagram maps these pins to Arduino pins 10 and 9 respectively. 10 didn't work for me (even with changing if(speakerPin==11)... to a 10, but pin 9 worked fine.
The Mega and the Uno have completely different mappings from timers to pins,
on the Mega timer1 controls pins 11, 12 and 13, on the uno it controls pins 9 and 10.