Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No such file or directory error] when running documentation examples #26

Closed
wangsix opened this issue Feb 26, 2016 · 7 comments
Closed

Comments

@wangsix
Copy link
Contributor

wangsix commented Feb 26, 2016

I probably missed something very basic. So I was trying to test the muda code examples from the documentation as follows.

jams_obj = muda.load_jam_audio(jam_file, song_file)
pitch = muda.deformers.LinearPitchShift(n_samples=5, lower=-2, upper=2)

for i, jam_out in pitch.transform(jams_obj):
    muda.save('output_{:02d}.wav'.format(i),
              'output_{:02d}.jams'.format(i),
               jam_out)

and I encountered the following error message:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-11-589bfe4aecc5> in <module>()
----> 1 for i, jam_out in pitch.transform(jams_obj):
      2     muda.save('output_{:02d}.ogg'.format(i),
      3               'output_{:02d}.jams'.format(i),
      4                jam_out)

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/muda/base.pyc in transform(self, jam)
    141 
    142         for state in self.states(jam):
--> 143             yield self._transform(jam, state)
    144 
    145     @property

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/muda/base.pyc in _transform(self, jam, state)
    109 
    110         if hasattr(self, 'audio'):
--> 111             self.audio(jam_w.sandbox.muda, state)
    112 
    113         if hasattr(self, 'metadata'):

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/muda/deformers/pitch.pyc in audio(mudabox, state)
     75         mudabox._audio['y'] = pyrb.pitch_shift(mudabox._audio['y'],
     76                                                mudabox._audio['sr'],
---> 77                                                state['n_semitones'])
     78 
     79     @staticmethod

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyrubberband/pyrb.pyc in pitch_shift(y, sr, n_steps, rbargs)
    163     rbargs.setdefault('--pitch', n_steps)
    164 
--> 165     return __rubberband(y, sr, **rbargs)

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyrubberband/pyrb.pyc in __rubberband(y, sr, **kwargs)
     64         arguments.extend([infile, outfile])
     65 
---> 66         subprocess.check_call(arguments)
     67 
     68         # Load the processed audio.

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.pyc in check_call(*popenargs, **kwargs)
    533     check_call(["ls", "-l"])
    534     """
--> 535     retcode = call(*popenargs, **kwargs)
    536     if retcode:
    537         cmd = kwargs.get("args")

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.pyc in call(*popenargs, **kwargs)
    520     retcode = call(["ls", "-l"])
    521     """
--> 522     return Popen(*popenargs, **kwargs).wait()
    523 
    524 

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
    708                                 p2cread, p2cwrite,
    709                                 c2pread, c2pwrite,
--> 710                                 errread, errwrite)
    711         except Exception:
    712             # Preserve original exception in case os.close raises.

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
   1333                         raise
   1334                 child_exception = pickle.loads(data)
-> 1335                 raise child_exception
   1336 
   1337 

OSError: [Errno 2] No such file or directory

Please give me any pointers on what I have been missing... I checked the content of jams_obj and the audio is loaded.

@bmcfee
Copy link
Owner

bmcfee commented Feb 26, 2016

Yikes, that's the least helpful error message I've ever seen.

The first thing I can think of: do you have rubberband installed and in your path?

@wangsix
Copy link
Contributor Author

wangsix commented Feb 26, 2016

Thank you so much Brian! Rubberband was not installed as you said. Thank you for pointing that out for me. Now the same code returns the following:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-6-ba2efbb97ebe> in <module>()
----> 1 for i, jam_out in pitch.transform(jams_obj):
      2     muda.save('output_{:02d}.wav'.format(i),
      3               'output_{:02d}.jams'.format(i),
      4                jam_out)

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jams/core.pyc in __getitem__(self, key)
    262     def __getitem__(self, key):
    263         """Dict-style interface"""
--> 264         return self.__dict__[key]
    265 
    266     def __setattr__(self, name, value):

KeyError: 0

I could only guess am I using the generator in a wrong way?

@bmcfee
Copy link
Owner

bmcfee commented Feb 26, 2016

Oh, I think maybe that iterator should be wrapped as enumerate(pitch.transform(jams_obj))?

(Currently on mobile, otherwise would test it myself)

@wangsix
Copy link
Contributor Author

wangsix commented Feb 26, 2016

You are right! I should have spot that as well. Just FYI, I was lazily copying the code from the documentation. I just added enumerate() and it worked! Thank you!

@bmcfee
Copy link
Owner

bmcfee commented Feb 26, 2016

Glad it's working, and sorry for the incorrect example code! I'll fix it when I'm back on a real machine.

Alternately, a PR would be greatly appreciated if you want to take a stab at it.

Thanks for pointing this out!

@wangsix
Copy link
Contributor Author

wangsix commented Feb 27, 2016

No problem, I will do a PR later!

On Feb 26, 2016, at 15:51, Brian McFee notifications@github.com wrote:

Glad it's working, and sorry for the incorrect example code! I'll fix it when I'm back on a real machine.

Alternately, a PR would be greatly appreciated if you want to take a stab at it.

Thanks for pointing this out!


Reply to this email directly or view it on GitHub.

@bmcfee
Copy link
Owner

bmcfee commented Feb 27, 2016

I'm closing this one out -- I think the original cause of this report is better handled within pyrubberband.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants