title: how to play mp3
body: <p>my problem starts here:</p>
  
  <p><a href="https://stackoverflow.com/questions/36323564/pyttsx-and-gtts-module-errors">pyttsx and gTTS module errors</a> </p>
  
  <p>gTTS works well, takes text from text file, but first creates mp3 file, then if I want listen, I must call this mp3, so it is good but it would be better if I can avoid any audio files, and get just read from text file. maybe somehow I can use google voice to read from text file..? anyway main question now is other</p>
  
  <p>if I can use only gTTS what is the best way to play mp3 on Windows 10-64 bit, Python 3.5 </p>
  
  <p>ok with os: </p>
  
  <pre><code>import os
  os.startfile("D:\my path/rec1.mp3") 
  </code></pre>
  
  <p>it is good, but I don't want use default player, need something like simpleaudio for mp3... </p>
  
  <p>with pygame I have installation problem and  not sure, how good is use it this way:</p>
  
  <pre><code>from pygame import mixer 
  
  mixer.init()
  mixer.music.load('D:/my path/rec1.mp3')
  mixer.music.play()
  </code></pre>
  
  <p>vlc just how to install it? with <code>easy_install vlc</code> I got error: <code>could not find suitable distribution for requirement.parse ('vlc')</code> and with <code>pip install vlc</code> error: <code>could not find a version that satisfies the requirement vlc (from versions: ) no matching distribution found for vlc</code> </p>
  
  <pre><code>import vlc
  
  p = vlc.MediaPlayer("file:/my path/rec1.mp3")
  p.play()
  p.stop()
  </code></pre>
  
  <p>with pyglet: </p>
  
  <pre><code>import pyglet
  
  music=pyglet.media.load('D:/my path/rec1.mp3')
  music.play()
  pyglet.app.run()
  </code></pre>
  
  <p>I got this error:</p>
  
  <pre><code>'AVbin is required to decode compressed media')
  pyglet.media.riff.WAVEFormatException: AVbin is required to decode compressed media
  </code></pre>
  
  <p>subprocess also uses default player:</p>
  
  <pre><code>import subprocess
  
  sound_program = "path to player"
  sound_file = "D:/my path/rec1.mp3"
  subprocess.call([sound_program, sound_file])
  </code></pre>
  
  <p>with mp3play, not sure how to use it: </p>
  
  <pre><code>import mp3play
  
  filename = (r'D:\my path/rec1.mp3')
  clip = mp3play.load(filename)
  clip.play()
  </code></pre>
  
  <p>I tried it this way: </p>
  
  <pre><code>  filename = ('D:\my path/rec1.mp3')
  </code></pre>
  
  <p>this way: </p>
  
  <pre><code>  filename = r'D:\my path/rec1.mp3'
  </code></pre>
  
  <p>In all cases I got error: </p>
  
  <pre><code>Traceback (most recent call last):
    File "D:/dt/PyCharm_project/0_ASK.py", line 18, in &lt;module&gt;
      import mp3play
    File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\mp3play\__init__.py", line 4, in &lt;module&gt;
      from .windows import AudioClip as _PlatformSpecificAudioClip
    File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\mp3play\windows.py", line 27
      print 'Error %s for "%s": %s' % (str(err), txt, buf)
                                  ^
  SyntaxError: invalid syntax
  </code></pre>
  
  <p>ok so with pydub: </p>
  
  <pre><code>from pydub import AudioSegment 
  from gtts import gTTS
  import simpleaudio as sa
  
  blabla = ('my voice')
  tts = gTTS(text=blabla, lang='en')
  tts.save("D:/my path/rec.mp3")
  
  rec = AudioSegment.from_mp3("D:\my path\rec.mp3")
  rec.export("rec.wav", format="wav")
  
  #rec = AudioSegment.ffmpeg ("D:\my path\rec.mp3")
  #rec.export("rec.wav", format="wav")
  
  #rec = AudioSegment.converter ("D:\my path\rec.mp3")
  #rec.export("rec.wav", format="wav")
  
  wave_obj = sa.WaveObject.from_wave_file('D:/my path/rec.wav'')
  play_obj = wave_obj.play()
  play_obj.wait_done()
  </code></pre>
  
  <p>Errors in the sequence first with <code>AudioSegment.from_mp3</code> :</p>
  
  <pre><code>RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
    warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
  Traceback (most recent call last):
    File " D:/dt/PyCharm_project/0_ASK.py", line 9, in &lt;module&gt;
      rec = AudioSegment.from_mp3("D:\my path\rec.mp3")
    File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\pydub\audio_segment.py", line 438, in from_mp3
      return cls.from_file(file, 'mp3')
    File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\pydub\audio_segment.py", line 366, in from_file
      file = _fd_or_path_or_tempfile(file, 'rb', tempfile=False)
    File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\pydub\utils.py", line 59, in _fd_or_path_or_tempfile
      fd = open(fd, mode=mode)
  OSError: [Errno 22] Invalid argument: 'D:\my path\rec.mp3'
  </code></pre>
  
  <p>with <code>AudioSegment.ffmpeg</code> :</p>
  
  <pre><code>  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
  Traceback (most recent call last):
    File "D:/dt/PyCharm_project/0_ASK.py ", line 12, in &lt;module&gt;
      rec = AudioSegment.ffmpeg ("D:\my path\rec.mp3")
  TypeError: 'str' object is not callable
  </code></pre>
  
  <p>with <code>AudioSegment.converter</code>:</p>
  
  <pre><code>RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
    warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
  Traceback (most recent call last):
    File "D:/dt/PyCharm_project/0_ASK.py", line 15, in &lt;module&gt;
      rec = AudioSegment.converter ("D:\my path\rec.mp3")
  TypeError: 'str' object is not callable
  </code></pre>
  
  <p>not sure maybe webbrowser, but how to install it? </p>
  
  <pre><code>import webbrowser
  webbrowser.open("D:/my path/rec1.mp3")
  </code></pre>