title: How to convert a .wav file to a spectrogram in python3
body: <p>I am trying to create a spectrogram from a .wav file in python3. </p>
  
  <p>I want the final saved image to look similar to this image: </p>
  
  <p><a href="https://imgur.com/gTxhejW" rel="noreferrer"><img src="https://i.imgur.com/gTxhejW.jpg" title="source: imgur.com" /></a></p>
  
  <p>I have tried the following:</p>
  
  <p>This stack overflow post: 
  <a href="https://stackoverflow.com/questions/43284049/spectrogram-of-a-wave-file">Spectrogram of a wave file</a></p>
  
  <p>This post worked, somewhat. After running it, I got</p>
  
  <p><a href="https://imgur.com/lS4BW9q" rel="noreferrer"><img src="https://i.imgur.com/lS4BW9q.png" title="source: imgur.com" /></a></p>
  
  <p>However, This graph does not contain the colors that I need. I need a spectrogram that has colors. I tried to tinker with this code to try and add the colors however after spending significant time and effort on this, I couldn't figure it out!</p>
  
  <p>I then tried <a href="http://www.frank-zalkow.de/en/code-snippets/create-audio-spectrograms-with-python.html" rel="noreferrer">this</a> tutorial.</p>
  
  <p>This code crashed(on line 17) when I tried to run it with the error TypeError: 'numpy.float64' object cannot be interpreted as an integer.</p>
  
  <p>line 17: </p>
  
  <pre><code>samples = np.append(np.zeros(np.floor(frameSize/2.0)), sig)
  </code></pre>
  
  <p>I tried to fix it by casting </p>
  
  <pre><code>samples = int(np.append(np.zeros(np.floor(frameSize/2.0)), sig))
  </code></pre>
  
  <p>and I also tried</p>
  
  <pre><code>samples = np.append(np.zeros(int(np.floor(frameSize/2.0)), sig))    
  </code></pre>
  
  <p>However neither of these worked in the end.</p>
  
  <p>I would really like to know how to convert my .wav files to spectrograms with color so that I can analyze them! Any help would be appreciated!!!!!</p>
  
  <p>Please tell me if you want me to provide any more information about my version of python, what I tried, or what I want to achieve. </p>