AGX Xavier Play Audio File with Python Script

Hi,

I have following speaker which is connected to AGX Xavier Developer Kit over USB.

Speaker

When I open a wav file directly everything is OK.
But when I try to open same wav file with a python script, there is no sound! And there is no error message about python script. The script is very simple

import simpleaudio as sa

wave_obj = sa.WaveObject.from_wave_file("playAudio.wav")
play_obj = wave_obj.play()
play_obj.wait_done()

The same script runs on my laptop correctly.
So, how can I play my audio file on AGX Xavier Dev Kit using a python script?

Regards

Hi, What is the duration of the WAV file? Could you try this script with a longer duration clip (5/10sec.) ?

In addition, could you try to play this clip in a loop and share your observations?

My audio file was 3 sec.
I have tried the same script with 18sec. audio clip in the loop.
But the situation same. The code is running but there is no sound.

I don’t see anything related to JP BSP that could cause this issue. Could you try with other Python utilities/packages (pyaudio/playsound etc…)?

I have tried pyaudio and playsound packages.
The problem is same.
Should I select output device in my script?

Yes, You must configure/select USB Audio device for playback.

I googled that how I can select the output device in script but I couldn,’t find any way. Could you explain that?

Suggest to try setting correct audio device (USB speakers) using system sound settings (UI) before the playback. If that doesn’t work, try to use pyaudio for playback with correct device index. Device list index can be checked as mentioned here. Feel free to explore further to get unblocked.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.