in other cases this is the full code I am doing here I am using paplay but no success I got theso I want to explore other optionsprint("Failed to play the audio file.")Code:
def play_wave_file(self, filename): """Play the recorded wave file.""" try: subprocess.run(["/usr/bin/paplay", filename], check=True) #print("Playback finished.") except subprocess.CalledProcessError: print("Failed to play the audio file.")
It's another case of knowing that it failed without knowing why. As with any other troubleshooting you need the why or you're just guessing. And as I've already stated, I don't guess.
Try changing that function to the following and see if it sheds some light on things:
Code:
def play_wave_file(self, filename): """Play the recorded wave file.""" try: result = subprocess.run(["/usr/bin/paplay", filename], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) result.check_returncode() except subprocess.CalledProcessError: print("Failed to play the audio file.") print(result.stdout.decode())You need .decode() because the data returned will almost certainly be a byte string not a "normal" python string.
Statistics: Posted by thagrol — Mon May 06, 2024 11:44 pm