A couple of things come to mind. Start with the simple stuff.
Look for small rocks anywhere on the bike, assuming you can't localize the sound. You an pick them up anytime you ride and the will lodge themselves into interesting places. They seem to rattle at specific RPM ranges. Loose accessories will do this too.
The more technical possibility is a defective catalytic converter. The catalyst separates within the converter causing a loud noise. It sounds a lot different than the sound you hear when the bike exhaust cools down. This is more of a possibility if you have an aftermarket exhaust. This should be easy to confirm. Once they take off the exhaust, just shaking it will move the catalyst around confirming your problem.