Check out example codes for "youtube-dl mp3 only". It will help you in understanding the concepts better.

Code Example 1

youtube-dl -x --audio-format mp3 <youtube-link>

Code Example 2

youtube-dl --extract-audio --audio-format mp3 <video URL>

Learn ReactJs, React Native from akashmittal.com