Show audio player only in specific post type

This is untested, but it seems to me that you could simply replace the:

$audio = "<audio src="https://wordpress.stackexchange.com/questions/382777/$url" controls autoplay loop></audio>";

with

$autoplay = is_singular( 'your_post_type' ) ? 'autoplay' : '';
$audio = "<audio src="https://wordpress.stackexchange.com/questions/382777/$url" controls $autoplay loop></audio>";

I.e. We use the $autoplay variable to store the autoplay attribute, and if the current page is the single page for your post type (your_post_type), then we set the variable value to autoplay.

But if you want to add/enable the audio player only on your custom post type pages, then you just need to change the is_singular() in your code to is_singular( 'your_post_type' ). Something like:

function wpse_67108_autplay_music( $content )
{
    if ( ! is_singular( 'your_post_type' ) )
    {
        return $content;
    }

    // ... the rest of your code here.
}