W. Weiss
W. Weiss

Reputation: 103

What is my syntax error reading .wav file?

I am coding in python and am trying get data from a .wav file so that I can perform a FFT and use that result to determine the freq of the note played.
This is what I have tried:

enter image description here

and this is the error I am getting:

enter image description here

Upvotes: 1

Views: 262

Answers (2)

Mureinik
Mureinik

Reputation: 310993

Strings, such as the path to your file, need to be denoted by quotes ('s) or double quotes ("s):

harp = wav.open('/Users/williamwiess2/Desktop/Test 2/harp.wav', 'r');
# Here ---------^--------------------------------------------^

Upvotes: 0

TessellatingHeckler
TessellatingHeckler

Reputation: 28963

The syntax error is that / is the math division operator (10/2, val1/val2) and needs numbers on either side, and opening a function call into a division with no numbers is a nonsense - invalid.

Your filename needs to be a string - enclosed in quotes.

harp = wave.open('/path/to/file', 'r')

(And it presumably needs to be wave.open not wav.open)

Upvotes: 1

Related Questions