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!