how do I store a few seconds of an mp3 stream using matlab.net.http?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Infinite_king
2024 年 5 月 29 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Audio and Video Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!