What can cause a MacBook Pro mid 2015 sound output to fade rapidly to silence? Today when i am using my mbp 2015 retina , sound went off suddenly.
Internal speaker or headphones are silent. I can only get sound from hdmi output.

Sound settings seem ok to me.

Some unspecified Diagnostic shows no problems.

No red lights in headphone jack.
I have reset the nvram and smc. With headphones, 8 hear sound just for a second but that fades out very quickly. I am running OS X mojave and don’t know how to fix this.
The amplifier to make sound is the likely cause of failure. Since that’s on the logic board, a free warranty swap or a flat rate repair for $300 or so are the likely costs to fix this properly. 

Have you tested installing a new OS on an external drive or wiping and reinstalling in case it’s software? That’s worth doing so you have a backup or confidence you need a repair as well.