Warning: Unable to play audio because no audio outputs were found.
Mostrar comentarios más antiguos
Hey, I'm trying to play an mp3 file on MATLAB, but it's giving me this error:
Warning: Unable to play audio because no audio outputs were found.
> In audiovideo.internal/audioplayerDesktop/hasNoAudioHardware (line 565)
In audiovideo.internal/audioplayerDesktop/play (line 228)
In audioplayer/play (line 349)
In sound (line 77)
This is my code:
[y,Fs] = audioread('Applause.mp3');
sound(y,Fs);
I'm not sure what I'm doing wrong...
2 comentarios
Charlie Ford
el 27 de Jul. de 2023
I'm running a MATLAB instance on a server which has no audio hardware (and I'm OK with the lack of audio h/w).
I'd like to avoid the orange stack trace.
How can I instruct MATLAB to deal more gracefully with a "null audioplayer" due to absence of audio h/w ?
Walter Roberson
el 28 de Jul. de 2023
Have you experimented with warning to turn the individual warning off? See lastwarn to figure out what the appropriate identifier for it is.
You might even want to go as far as to warning('') first to clear the last warning, then check lastwarn() afterwards to see if the warning was given, with the goal of skipping any appropriate steps in your code that will not work without audio.
Respuestas (5)
Vinai Datta Thatiparthi
el 13 de Abr. de 2020
Hello Anthony,
This error could be the result of the path being modified, or the necessary libraries being removed to access the sound components on the computer. To fix this, in the command window, use -
restoredefaultpath
rehash toolboxcache
savepath
Further, evaluate if MATLAB is able to read the available outputs for audio on your PC using the function audiodevinfo. This results in a struct array containing all available & recognized audio inputs/outputs.
info = audiodevinfo
In case info returns an empty struct, it could be because of faulty drivers. Update all your drivers or disable devices one at a time and restart MATLAB and try 'audiodevinfo' to figure out if one or more devices has a possible faulty driver.
Instead, if info returns a struct with available outputs for audio (non-empty), you should be able to play the audio using audioplayer object. Additionally, if info has recognized multiple audio outputs, you can also use "device ID" to specify the output audio device.
Hope this helps!
4 comentarios
Van Cygnon Tango
el 23 de Oct. de 2021
Hi Vinai,
I had the same problem as Anthony and it was cured thanks to your solution. You got my upvote!
Mary Brown
el 30 de Mayo de 2022
This did not work for me. I still get an error message. I'm trying to play an audio file from code listed in an textbook for a MATLAB class in Coursera. In the function window, this is the code I typed:
function play_tone(f)
Fs=8192;
t = 0:1/Fs:1;
tone=sin(f*2*pi*t);
sound(tone,Fs);
In the command window, I type play_tone(147)
I get the following error message below. How do I set the audio outputs?
Warning: Unable to play audio because no audio outputs were found.
> In audiovideo.internal/audioplayerDesktop/hasNoAudioHardware (line 565)
In audiovideo.internal/audioplayerDesktop/initialize (line 354)
In audiovideo.internal.audioplayerDesktop (line 198)
In audioplayer (line 130)
In sound (line 74)
In play_tone (line 5)
Warning: Unable to play audio because no audio outputs were found.
> In audiovideo.internal/audioplayerDesktop/hasNoAudioHardware (line 565)
In audiovideo.internal/audioplayerDesktop/play (line 228)
In audioplayer/play (line 349)
In sound (line 77)
In play_tone (line 5)
Walter Roberson
el 3 de Jun. de 2022
If you are using matlab online then audio can only be used with Chrome browser.
沁禾 彭
el 28 de Jul. de 2022
thanks a lot! Your answer helps me so much!
Guilherme Vitor Santos
el 3 de Jun. de 2022
1 voto
estou com esse poblema matlab online
Error evaluating 'InitFcn' callback of Audio Device Writer block (mask) 'lllabtetecom/Audio Device Writer'.
Callback string is 'audioblkAudioDeviceIO(gcbh, 'initfcn');'
Caused by:
No audio input device detected
1 comentario
Walter Roberson
el 3 de Jun. de 2022
If you are using matlab online then audio can only be used with Chrome browser.
Image Analyst
el 3 de Jun. de 2022
0 votos
This happens to me a lot. I have a PlaySoundFile() function that plays a sound file through the speakers. I'm using MATLAB desktop, not online. I have to do the restoredefaultpath to fix it. Then it's fixed for a while but something causes it to break again and I'll get the error message again
In PlaySoundFile (line 74)
Warning: Unable to play audio because no audio outputs were found.
> In audiovideo.internal/audioplayerDesktop/hasNoAudioHardware (line 565)
In audiovideo.internal/audioplayerDesktop/play (line 228)
In audioplayer/play (line 349)
In sound (line 77)
In PlaySoundFile (line 74)
I wish I could figure out what is causing it to break. I don't believe it's because I'm removing sound libraries. I do set the path to some folders in my startup.m file but that happens every time I start MATLAB and it works fine until some mysterious process causes it to break, so it's not adding things to the path that's causing it to break.
Jonas
el 13 de Jul. de 2022
0 votos
anything new on this topic? can't make matlab to play sounds again, there are audio devices available, resetting/rehashing has not the effect i hoped to see. Only a matlab restart can resolve this for me, but i need to reset on runtime, e.g. if this issue comes up during use of a self created app
6 comentarios
Image Analyst
el 13 de Jul. de 2022
Not that I've heard of. What version are you using? I'm using the R2022b pre-release and I don't think it's happened to me there yet, though I don't remember playing sound files there much. It certainly works after it's been open not long, as with the other versions. I'm not sure what happens to eventually break it.
I am using 2022a release. I cannot reproduce the problem reliably, I have the feeling the problem occurs if no audio device is plugged in when starting matlab and it is plugged in later. Resetting the audiodevice list using audiodevreset() brings up the plugged in devices in the list, but I can't make Matlab play any sound, neither using soundsc(), nor with audioplayer, be it with or without explicit device ID
using any of the previous suggestions like
restoredefaultpath
rehash toolboxcache
savepath
does not make any difference for me
Image Analyst
el 14 de Jul. de 2022
That's good information. I'll check that next time. I'm not in a "broken" state now so everything works fine but if it fails, then I'm going to check
info = audiodevinfo;
Image Analyst
el 19 de Jul. de 2022
OK, it broke again. Here's what I see
> In audiovideo.internal/audioplayerDesktop/hasNoAudioHardware (line 565)
In audiovideo.internal/audioplayerDesktop/play (line 228)
In audioplayer/play (line 349)
In sound (line 77)
In PlaySoundFile (line 74)
>> info = audiodevinfo
info =
struct with fields:
input: [1×4 struct]
output: []
So it sees 4 input microphones, but none of the output speakers for the 4 audio systems (internal, headset, etc.).
Jonas
el 19 de Jul. de 2022
did you try audiodevreset() and looked into the information again?
Image Analyst
el 19 de Jul. de 2022
@Jonas, no because I restarted and it's working again. It's not currently broken (yet). That (audiodevreset) might be a faster way to fix it than restarting. I can try it. But we'd really like to know what happened to break it in the first place so we don't have to fix it.
Miguel corona palacios
el 27 de Sept. de 2023
0 votos
buenas noches, yo tambien tengo ese mismo problema. tengo una laptop dell quizas unos 5-10 años vieja y si se escucha el sonido, pero con una nueva hp, me marca erro, que puediera ser_
Warning: Unable to play audio because no audio outputs were
found.
> In audiovideo.internal/audioplayerDesktop/hasNoAudioHardware (line 565)
In audiovideo.internal/audioplayerDesktop/initialize (line 354)
In audiovideo.internal.audioplayerDesktop (line 198)
In audioplayer (line 130)
In sound (line 74)
Warning: Unable to play audio because no audio outputs were
found.
> In audiovideo.internal/audioplayerDesktop/hasNoAudioHardware (line 565)
In audiovideo.internal/audioplayerDesktop/play (line 228)
In audioplayer/play (line 349)
In sound (line 77)
Categorías
Más información sobre Audio and Video Data en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!