Audio plays during i2samp.sh, but not in codes

the robot hat speakers are not playing any sound at all from my code regardless the code is running well and i also run the example “tts_example” code, it didn’t play the sounds at all except when i run “sudo bash i2samp.sh” what should i do?

If you want the robot to sound, you have to run the script i2samp.sh to install the components needed for the i2s amplifier, otherwise the robot will have no sound.
You only need to install them once. After that, every time you run the example related to the audio example, it will sound properly.
If you have installed i2samp.sh and the robot still does not make sound when running the audio examples, run the i2samp.sh script several times.
Or execute the following sudo killall pulseaudio command.