title: How to get only 30 seconds of a song using python
body: <p>I want when i play a song in python it only plays the first 30 seconds of a song only no matter the length of it. I want this to be done without creating a new mp3 file. I have pydub but what is actually doing is creating a new file with 30 seconds cut which is taking too long to load on my Django page.</p>
  <pre><code>   startMin = 9
     startSec = 50
  
     endMin = 13
     endSec = 30
  
     # Time to miliseconds
     startTime = startMin*60*1000+startSec*1000
     endTime = endMin*60*1000+endSec*1000
  
     # Opening file and extracting segment
     song = AudioSegment.from_mp3( item_media.file.path )
     extract = song[startTime:endTime]
  
     extract.export( 'Zoo'+'-extract.mp3', format=&quot;mp3&quot;)
  </code></pre>