Jetson nano audio looping skipping

I have a jetson nano and im trying to play a sound on a loop,
im doing a basic sound playing with pyaudio on a basic python loop, it looks like this:

for i in range(10):
    new_player = Player(device=player_device, file='test.wav')
    data = new_player.wav_file.readframes(new_player.chunk_size)
        print(f"Playing {new_player.file_name}")
        while data:
            new_player.stream.write(data)
            data = new_player.wav_file.readframes(new_player.chunk_size)
    new_player.wav_file.rewind()
    new_player.stream.stop_stream()
    new_player.close()

for some reason as im running the code for 10 times, 1-3 out of the 10 iterations doesn’t actually play the sound on the speaker, am i missing something?

Hi irmir10,

Which device/interface is used for the playback ? (Is it HDMI/USB/I2S?)

Also, what is the playback duration of this clip (test.wav)? Is it possible to attach the clip here?

Thanks,
Sharad

Hi Sharad,

The device used for playback is mobile speaker through a USB to 3.5mm jack.

the playback clip is a 0.66 sec generic buzzing sound.

Thanks,

Could you please try below:

  • Back to back playback with a longer duration clip (~2 sec).
  • Add sleep/delay between close and start of the player.

Thanks,
Sharad

I have tried putting a 2sec sleep and it still skipped.
And the sound has to be 0.66 sec

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

Hi irmir10,

Sorry for the delay. Could you try playback with Simpleaudio : “Simpleaudio Package — simpleaudio 1.0.4 documentation” and share observations?

import simpleaudio as sa
for i in range (10):
    wave_obj = sa.WaveObject.from_wave_file("test.wav")
    play_obj = wave_obj.play()
    play_obj.wait_done()

Thanks,
Sharad