title: how to play wav file in python?
body: <p>I tried pygame for playing wav file like this:</p>
  
  <pre><code>import pygame
  pygame.init()
  
  pygame.mixer.music.load("mysound.wav")
  pygame.mixer.music.play()
  pygame.event.wait()
  </code></pre>
  
  <p>but It change the voice and I don't know why!
  I read <a href="https://stackoverflow.com/questions/307305/play-a-sound-with-python">this link</a> solutions and  can't solve my problem with playing wave file!</p>
  
  <p>for this solution I dont know what should I import?</p>
  
  <pre><code>s = Sound() 
  s.read('sound.wav') 
  s.play()
  </code></pre>
  
  <p>and for this solution /dev/dsp dosen't exist in new version of linux :</p>
  
  <pre><code>from wave import open as waveOpen
  from ossaudiodev import open as ossOpen
  s = waveOpen('tada.wav','rb')
  (nc,sw,fr,nf,comptype, compname) = s.getparams( )
  dsp = ossOpen('/dev/dsp','w')
  try:
    from ossaudiodev import AFMT_S16_NE
  except ImportError:
    if byteorder == "little":
      AFMT_S16_NE = ossaudiodev.AFMT_S16_LE
    else:
      AFMT_S16_NE = ossaudiodev.AFMT_S16_BE
  dsp.setparameters(AFMT_S16_NE, nc, fr)
  data = s.readframes(nf)
  s.close()
  dsp.write(data)
  dsp.close()
  </code></pre>
  
  <p>and when I tried pyglet It give me this error:</p>
  
  <pre><code>import pyglet
  
  music = pyglet.resource.media('mysound.wav')
  music.play()
  
  pyglet.app.run()
  --------------------------
  
  nima@ca005 Desktop]$ python play.py
  Traceback (most recent call last):
    File "play.py", line 4, in &lt;module&gt;
      music = pyglet.resource.media('mysound.wav')
    File "/usr/lib/python2.7/site-packages/pyglet/resource.py", line 587, in media
      return media.load(path, streaming=streaming)
    File "/usr/lib/python2.7/site-packages/pyglet/media/__init__.py", line 1386, in load
      source = _source_class(filename, file)
    File "/usr/lib/python2.7/site-packages/pyglet/media/riff.py", line 194, in __init__
      format = wave_form.get_format_chunk()
    File "/usr/lib/python2.7/site-packages/pyglet/media/riff.py", line 174, in get_format_chunk
      for chunk in self.get_chunks():
    File "/usr/lib/python2.7/site-packages/pyglet/media/riff.py", line 110, in get_chunks
      chunk = cls(self.file, name, length, offset)
    File "/usr/lib/python2.7/site-packages/pyglet/media/riff.py", line 155, in __init__
      raise RIFFFormatException('Size of format chunk is incorrect.')
  pyglet.media.riff.RIFFFormatException: Size of format chunk is incorrect.
  AL lib: ReleaseALC: 1 device not closed
  </code></pre>