title: remove silence at the beginning and at the end of wave files with PyDub
body: <p>How can I remove the silence from the beginning and the end of wave files with PyDub? </p>
  
  <p>I guess I should access segment by segment and check whether it's silent or not (but I'm not able to do it) :/</p>
  
  <p>e.g. I have a wave file with silence at the beginning, end, or both (like below) and I want to remove the silence at the beginning and at the end of the file:</p>
  
  <p><img src="https://s15.postimg.org/n37i2spnv/figure_wav.png" alt="wave file with silence"></p>
  
  <p>e.g. I want to import it </p>
  
  <pre><code>sound = AudioSegment.from_wav(inputfile)
  </code></pre>
  
  <p>cycle for every sample of sound to check whether it's silent and mark the last silent sample since when the waves starts (marker1),
  then get to the last sample before the wave ends (marker2) and I can export the new sound file from the two markers</p>
  
  <pre><code>newsound = sound[marker1:marker2]
  
  newsound.export(outputfile, format="wav")
  </code></pre>