How can I get my audio files to work for WEBGL build?

As soon as I switch over to WEBGL build all my audio files lose the option to preview, cannot be dragged into an Audioclip box and when I run game no sound plays at all, not in my editor or in the final build. I have tried bringing in .ogg, .wav and .mp3 and they all do the exact same error mentioned above. I see other unity games with sound so I know it must be possible. tried checking “override for WEBGL” in import settings which removes error message but does not fix the problem. Running Unity 2021 but same problem with 2019. Any help greatly appreciated, thanks!!

I have a webgl project where sound is working so it should be able to work.

It’s like the metadata files are gone or something.
Check your folder where you keep the sounds (Assets/Sound). Maybe regenerate the import settings by emptying that folder and copy the sound files there again.

Attaching images from my project and it directly recognize the sound files and build icons for them. Maybe it can help you.183302-sound-webgl-metadata.jpg

finally got it fixed! I followed the steps in answer below then restarted Unity

Why can't I hear my audio? - Questions & Answers - Unity Discussions.

And in between restarting I changed my music files open with preference from ‘groove music’ to ‘windows media player’ then re-dragged in sound. I figure following steps from above link is what did it but might as well mention the second action as I’m not sure which one fixed it.

I also had this error while converting Unity Tower Defense Template to WebGL. It would play normally in the editor, but whenever i tried to build and run it, it’ll fail. In the editor, although, it was working fine, it didn’t had any sound. Itried chaging it but it would not let me cange the audio, as the OP has listed the issue.
What I did to solve the problem? I made a new Unity project. Then changed its targeted platform to WebGL. And then I imported the package. Worked all right.
Also, i had Windows 10 Pro N. So i had to download Windows Media Foundation as well. I’m not sure if its necessary but, it didn’t helped me. Changing the platform first and then importing the unitypackage did help. Hope this helps