Filter löschen
Filter löschen

how do I store a few seconds of an mp3 stream using matlab.net.http?

2 Ansichten (letzte 30 Tage)
David Sears
David Sears am 31 Mär. 2021
Beantwortet: Infinite_king am 29 Mai 2024
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.

Antworten (1)

Infinite_king
Infinite_king am 29 Mai 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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by