how do I store a few seconds of an mp3 stream using matlab.net.http?
1 view (last 30 days)
Show older comments
I'd like to assign 5 seconds of audio from the following http mp3 stream to a matlab variable using matlab.net.http:
I'm new to matlab.net.http, so any suggestions would be most welcome.
0 Comments
Answers (1)
Infinite_king
on 29 May 2024
Hi David Sears,
The simplest solution is to download the entire audio and then cut out the unnecessary portion. This can be easily achieved using 'webread'.
% Downloading the audio into MATLAB variables
options = weboptions("ContentType", "audio");
[data, fs] = webread('http://radio.garden/api/ara/content/listen/tMGsmGxF/channel.mp3', options);
% Method 1 ---------------------------
% Saving the audio
audiowrite('audio.mp3', data, fs);
% Reading the first 5 seconds of the audio
[data2, fs2] = audioread('audio.mp3', [1, 5 * fs]);
% Method 2 ----------------------------
% Directly trim the audio from raw data
data3 = data(1:5 * fs, :);
For more information on the above MATLAB functions, refer the following resources,
Hope this is helpful.
0 Comments
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!