Please try the following template:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="music">
<xsl:copy>
<xsl:for-each select="*">
<xsl:element name="{name()}">
<xsl:attribute name="id">
<xsl:choose>
<xsl:when test="preceding::*/@id=current()/@id">
<xsl:value-of select="generate-id()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@id"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>