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

Compatibility with spleeter #102

Open
justonem0reuser opened this issue May 28, 2024 · 0 comments
Open

Compatibility with spleeter #102

justonem0reuser opened this issue May 28, 2024 · 0 comments

Comments

@justonem0reuser
Copy link

justonem0reuser commented May 28, 2024

Hello,
I've experienced these two issues when using crepe and spleeter libraries together, specifically when trying to call crepe.predict method after calling separate method of spleeter.
Here is a code in Google Colab:

!pip install crepe
!pip install spleeter
from spleeter.separator import Separator
from spleeter.audio.adapter import AudioAdapter
separator = Separator('spleeter:4stems')
audio_loader = AudioAdapter.default()
srate = 44100
audio1, _ = audio_loader.load('audio1.wav', sample_rate = srate)
audio2, _ = audio_loader.load('audio2.wav', sample_rate = srate)
separation = separator.separate(audio1)
import crepe
times1, freqs1, confidence1, activation1 = crepe.predict(audio1, srate, viterbi=True)

The output is following:


RuntimeError Traceback (most recent call last)

...

----> 2 times1, freqs1, confidence1, activation1 = crepe.predict(audio1, srate, viterbi=True)

4 frames

/usr/local/lib/python3.10/dist-packages/tensorflow/python/framework/ops.py in _check_not_finalized(self)
3321 """
3322 if self._finalized:
-> 3323 raise RuntimeError("Graph is finalized and cannot be modified.")
3324
3325 def _add_op(self, op, op_name):

RuntimeError: Graph is finalized and cannot be modified.

To avoid this, we can write the following commands instead of the last string:

import tensorflow as tf
with tf.Graph().as_default():
    times1, freqs1, confidence1, activation1 = crepe.predict(audio1, srate, viterbi=True)

In this case the prediction will be performed without errors.

But if we try to do another prediction after that, for example:

with tf.Graph().as_default():
    times2, freqs2, confidence2, activation2 = crepe.predict(audio2, srate, viterbi=True)

then we'll get the following error:


InvalidArgumentError Traceback (most recent call last)

in <cell line: 1>()
1 with tf.Graph().as_default():
----> 2 times2, freqs2, confidence2, activation2 = crepe.predict(audio2, srate, viterbi=True)

8 frames

/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py in init(self, session, callable_options)
1469 compat.as_bytes(callable_options.SerializeToString()))
1470 try:
-> 1471 self._handle = tf_session.TF_SessionMakeCallable(
1472 session._session, options_ptr)
1473 finally:

InvalidArgumentError: Tensor input:0, specified in either feed_devices or fetch_devices was not found in the Graph

To avoid this, we must call predict method for both files inside the same "with" section:

with tf.Graph().as_default():
    times1, freqs1, confidence1, activation1 = crepe.predict(audio1, srate, viterbi=True)
    times2, freqs2, confidence2, activation2 = crepe.predict(audio2, srate, viterbi=True)

But sometimes it is impossible.

The following versions were used:

  • python 3.10
  • crepe 0.0.15
  • spleeter 2.4.0
  • tensorflow 2.9.3
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

1 participant