필터 지우기
필터 지우기

How to read the audio information of a file directly from internet?

조회 수: 3 (최근 30일)
ashish kumar
ashish kumar 2018년 11월 20일
댓글: ashish kumar 2018년 11월 20일
% Enter your MATLAB Code below
options = weboptions('Timeout', 1000);
tStamp = datetime;
filename = webread('http://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_5MG.mp3', options);
a= plot(filename);
info = audioinfo(filename);
I am getting following error:
Error using audioinfo
Expected FILENAME to be one of these types:
char, string
Instead its type was matlab.graphics.chart.primitive.Line.
Error in audioinfo (line 48)
validateattributes(filename, {'char', 'string'}, {'vector'}, mfilename, 'FILENAME');
Error in Custom (no starter code) 5 (line 7)
info = audioinfo(a);
I am using Thingspeak as I am not having a working MATLAB license currently.

채택된 답변

Jan
Jan 2018년 11월 20일
편집: Jan 2018년 11월 20일
The error message is clear: webread replies the data delevered from the internet. Therefore the name of the variable "filename" is misleading. Store the obtained data in a file and use the file name as input for audioinfo. But then you get only the parameters which have been defined during writing the file. The original frequency must be requested directly:
[data, freq] = webread('http://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_5MG.mp3', options);
  댓글 수: 2
ashish kumar
ashish kumar 2018년 11월 20일
Hi Jan,
I am using Thingspeak for this purpose actually since I have lost my MATLAB license. In that I was able to do directly. but here I am not in ThingSpeak.
ashish kumar
ashish kumar 2018년 11월 20일
% Enter your MATLAB Code below
options = weboptions('Timeout', 1000)
[data, freq] = webread('http://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_5MG.mp3', options);
a = audioinfo(data,freq)
tout = 0:(a.Duration)
[y, Fs] = audioread(data,freq)
player = audioplayer(y, Fs)
sound(y,Fs)
tStamp = datetime
This is the updated code I ran on Thingspeak. It is able to read the data and freq and able to plot curve of spectrum, but for audioinfo it is throwing error.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

Help CenterFile Exchange에서 ThingSpeak에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by