detecting silence in an audio file using python 2.7
<p>I am using Python 2.7 and I am trying to write a script that can detect if the file is silent or not. I have tried some of the solutions that are already up on this site. I tried them and they make sense to me but the when I went to adapt it and test it the script is telling me that the files have audio even though having listened to the files I know that they are silent. I am a relative beginner with Python and I am sure most of my code is probably wrong! I would appreciate any help. (Also a lot of this code is based off similar answers on here!)
Here is my code:</p>

<pre><code>import wave
import contextlib
import glob 
path = '/home/ubuntu/'

folder = glob.glob('*.wav')

count = 0

THRESHOLD = 500

CHUNK_SIZE = 1024

RATE = 44100

for file in folder:

      with contextlib.closing(wave.open(file,'r')) as f:
      #Returns 'True' if below the 'silent' threshold"
           if file &lt; THRESHOLD:
              print (file + " is silent")
           else:
              print (file + " has audio")
</code></pre>