How can I load an AudioClip from a local audio file using UnityWebRequests?

I’m trying to make a rhythm game which allows for creation of custom levels. To accomplish this, I need to be able to load audio files from local folders. I can’t use the Resources folder because the user needs to be able to provide the song file themselves during level development.

I’ve been using the following method:

string songPath = "C:\Users\...\levels\[level name]\song.ogg"
using (var www = new WWW("file:///" + songPath))
{
     yield return www;
    song = www.GetAudioClip();
}
audioSource.clip = song;

It’s been working well, but the console gives me a warning saying that WWW is obsolete, and I should be using UnityWebRequests. I’d like to, to futureproof my game, but I can’t figure out how to do it.

How can I use UnityWebRequests to extract an AudioClip from a local audio file?

I figured it out. I tried a solution from a previous question by @seacharge which said that that solution did not work. However, it worked for me:

UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file:///" + songPath, AudioType.OGGVORBIS);
yield return req.SendWebRequest();
song = DownloadHandlerAudioClip.GetContent(req);

I don’t know where their solution went wrong, but it worked for me.