doesn't find audio harware
10 ビュー (過去 30 日間)
古いコメントを表示
when i want to play audio through matlab by use of audioread i get this error saying it doesn't find any audio hardware
> In audiovideo.internal.audioplayerDesktop.hasNoAudioHardware (line 566)
1 件のコメント
Walter Roberson
2024 年 10 月 10 日
Playing audio would require a function such as audiowrite() or sound() . audioread() is for inputting sound into MATLAB.
Quesiton: are you using MATLAB Online? If so then there is only audio capabilities if you are using the Chrome browser.
回答 (1 件)
Hitesh
2024 年 10 月 14 日
Hi Kevin,
The issue might occur because of multiple reasons, to troubleshoot, please ensure the following:
Verify the Audio File:
- Ensure that the audio file is not corrupted.
- Try playing the audio file using any media player to confirm it is working correctly.
Check MATLAB Preferences:
- Open MATLAB and navigate to Home > Preferences > MATLAB > Audio.
- Ensure that the correct audio device is selected. If no device is listed, MATLAB may not be detecting your audio hardware.
Use Appropriate Functions:
- Use the “audioread” function to read the audio file.
- Use the “sound” function to play the audio file.
Refer to the code below to help identify the root cause of the error:
% Read the audio file
filename = 'sample-3s.wav'; % Replace with your audio file
[y, Fs] = audioread(filename);
% Check if audio data is successfully read
if isempty(y)
error('Audio data could not be read. Check the file path and format.');
end
% Play the audio using the sound function
try
sound(y, Fs);
disp('Playing audio...');
catch ME
disp('An error occurred while trying to play audio.');
disp(ME.message);
end
For more information about the "audioread" and "sound", refer to the below MATLAB documenation,
If the issue persists, could you please share the audio file that is causing this error? So that I can investigate the issue.
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!