Speaker not working on Iphone 4s?

Whenever i listen to something on my phone the speaker goes on and off every couple of minutes when I use headphones or just the speakers on the phone. When I use the speakers the noise sounds really static and voices sound robotic. Why is it doing this?

Not sure but my phone is doing the same. I will buy a Samsung next time.