Problems in commands.getoutput(cmd) with sox

B

bbarbero

Hello to all!

I am a new researcher, new to Python as well, and I have a problem,
when I try to get commands from sox in a python script. I am going
crazy, because this code has been working before.. so I dont really
know whats going on..

Ive already seen some solutions that match with what I have. I am
running this:



if os.path.splitext(file_au)[1] == ".au":
resampled_file_path = os.path.join(resampled_path, file_au)
cmd = "sox " + dir_file + " -r 44100 " + resampled_file_path
print cmd
output = commands.getoutput(cmd)
print output

What i do, is just to resample a song from dir_file to
resampled_file_path. As a result of "cmd" I get:

.....
sox /Volumes/HAL/Datasets/Audio/gtzan_genres/rock/rock.00097.au -r
44100
/Volumes/bmorab/Audio_Projecto/Data/gtzan_genres/resampled/rock/rock.00097.au
......

If I run this on the command line, it will work perfectly!

But The program stops at

File
"/Volumes/bmorab/Audio_Projecto/Data/gtzan_genres/resamplingto44.py",
line 35
output = commands.getoutput(cmd)
^
IndentationError: unexpected indent

I dont have any idea, whats going on, I am trying lot of things, but I
can understand where is the error as it has been running perfectly
before.

Any suggestions will be more than welcome! Thanks in advance for your help!

Best regards,
Beatriz Mora.
 
P

Peter Otten

Hello to all!

I am a new researcher, new to Python as well, and I have a problem,
when I try to get commands from sox in a python script. I am going
crazy, because this code has been working before.. so I dont really
know whats going on..

Ive already seen some solutions that match with what I have. I am
running this:



if os.path.splitext(file_au)[1] == ".au":
resampled_file_path = os.path.join(resampled_path, file_au)
cmd = "sox " + dir_file + " -r 44100 " + resampled_file_path
print cmd
output = commands.getoutput(cmd)
print output

What i do, is just to resample a song from dir_file to
resampled_file_path. As a result of "cmd" I get:

....
sox /Volumes/HAL/Datasets/Audio/gtzan_genres/rock/rock.00097.au -r
44100
/Volumes/bmorab/Audio_Projecto/Data/gtzan_genres/resampled/rock/rock.00097.au
.....

If I run this on the command line, it will work perfectly!

But The program stops at

File
"/Volumes/bmorab/Audio_Projecto/Data/gtzan_genres/resamplingto44.py",
line 35
output = commands.getoutput(cmd)
^
IndentationError: unexpected indent

I dont have any idea, whats going on, I am trying lot of things, but I
can understand where is the error as it has been running perfectly
before.

Any suggestions will be more than welcome! Thanks in advance for your
help!

You are probably mixing tabs and spaces and have set your editor to display
a tabsize != 8 spaces.

When you change the tabsize to 8 you will see the inconsistent indentation.

In the future you can avoid such problems by configuring your editor to
replace one tab with four spaces. Recommended reading:

http://www.python.org/dev/peps/pep-0008/

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top