-1

I have installed many libraries and tried many different codes but I'm not able to play the audio file on Raspberry Pi 3B+. If you know any method or have any code. Must recommend me.

  • 1
    ***I have installed many libraries and tried many different codes***: Which ones? Please be specific. `pyAudio` and `pygame` let you play music files. – Pedro Lobito Dec 16 '18 at 11:19
  • @PedroLobito , used `pyAudio`,`pygame` & `pyglet`. – Umer Farooq Dec 16 '18 at 11:26
  • 1
    And what errors did you get? There's no point in saying ***it didn't work***, if you don't specify the error which didn't allow the script to run properly. That's called debugging, a coder's life. – Pedro Lobito Dec 16 '18 at 11:28
  • 1
    @PedroLobito, thanks for your advice. I debugged my code. – Umer Farooq Dec 16 '18 at 12:34

1 Answers1

0

To Play a wav file on raspberry you can use pygame,i.e.:

import pygame
pygame.init()
pygame.display.set_mode(pygame.display.list_modes()[-1]) # smallest resolution available
pygame.mixer.init()
pygame.mixer.music.load('file.wav')
pygame.mixer.music.play()

while pygame.mixer.music.get_busy():
    pygame.time.Clock().tick(10)

Notes:

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268