AttributeError: 'tuple' object has no attribute 'dtype'
<p>I'm new to Python but a seasoned vet in other languages but why does data.dtype throw the error <code>AttributeError: 'tuple' object has no attribute 'dtype'</code> and how can I get the dtype value?</p>

<p>From <a href="http://samcarcagno.altervista.org/blog/basic-sound-processing-python/" rel="nofollow noreferrer">this</a> blog it looks like I should be able to just do <code>data.dtype</code></p>

<p>Code</p>

<pre><code>import pyaudio
import sys
import numpy
import scipy.io.wavfile

# Ensures that a file is passed in as an argument
if len(sys.argv) &lt; 2:
    print("Plays a wave file.\n\nUsage: %s filename.wav" % sys.argv[0])
    sys.exit(-1)

file = sys.argv[1];

# Read the file
data = scipy.io.wavfile.read(file)
rate = data[0]
print data
print "rate = ", rate
print data[1]
print "format = ", data.dtype
</code></pre>

<p>Output</p>

<pre><code>(44100, array([[0, 0],
       [0, 0],
       [0, 0],
       ..., 
       [0, 0],
       [0, 0],
       [0, 0]], dtype=int16))
rate =  44100
[[0 0]
 [0 0]
 [0 0]
 ..., 
 [0 0]
 [0 0]
 [0 0]]
format = 
Traceback (most recent call last):
  File "index.py", line 31, in &lt;module&gt;
    print "format = ", data.dtype
AttributeError: 'tuple' object has no attribute 'dtype'
</code></pre>