24d6f5e42d775949e191122091826eefa7bf1246,docs/examples/plot_viterbi.py,,,#,27

Before Change


plt.step(times, p>=0.5, label="Frame-wise")
plt.step(times, states, linestyle="--", color="orange", label="Viterbi")
plt.xlabel("Time")
plt.axis("tight")
plt.ylim([0, 1.05])
plt.legend()

After Change


ax[0].label_outer()
ax[1].step(times, p>=0.5, label="Non-silent")
ax[1].set(ylim=[0, 1.05])
ax[1].legend()

//////////////////////////////////////////////////////////////////////////////////////////////
// We can do better using the Viterbi algorithm.
// We"ll use state 0 to indicate silent, and 1 to indicate non-silent.
// We"ll assume that a silent frame is equally likely to be followed
// by silence or non-silence, but that non-silence is slightly
// more likely to be followed by non-silence.
// This is accomplished by building a self-loop transition matrix,
// where `transition[i, j]` is the probability of moving from state
// `i` to state `j` in the next frame.

transition = librosa.sequence.transition_loop(2, [0.5, 0.6])
print(transition)

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Our `p` variable only indicates the probability of non-silence,
// so we need to also compute the probability of silence as its complement.

full_p = np.vstack([1 - p, p])
print(full_p)

////////////////////////////////////////////////////////////////////////
// Now, we"re ready to decode!
// We"ll use `viterbi_discriminative` here, since the inputs are
// state likelihoods conditional on data (in our case, data is rms).

states = librosa.sequence.viterbi_discriminative(full_p, transition)

// sphinx_gallery_thumbnail_number = 5
fig, ax = plt.subplots(nrows=2, sharex=True)
librosa.display.specshow(librosa.amplitude_to_db(S_full, ref=np.max),
                         y_axis="log", x_axis="time", sr=sr, ax=ax[0])
ax[0].label_outer()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: librosa/librosa
Commit Name: 24d6f5e42d775949e191122091826eefa7bf1246
Time: 2020-06-27
Author: bmcfee@users.noreply.github.com
File Name: docs/examples/plot_viterbi.py
Class Name:
Method Name:


Project Name: librosa/librosa
Commit Name: 24d6f5e42d775949e191122091826eefa7bf1246
Time: 2020-06-27
Author: bmcfee@users.noreply.github.com
File Name: docs/examples/plot_superflux.py
Class Name:
Method Name:


Project Name: librosa/librosa
Commit Name: 24d6f5e42d775949e191122091826eefa7bf1246
Time: 2020-06-27
Author: bmcfee@users.noreply.github.com
File Name: docs/examples/plot_viterbi.py
Class Name:
Method Name:


Project Name: scikit-learn/scikit-learn
Commit Name: e650a207efc9dd33556b1b9678b043f73a18aecb
Time: 2019-11-14
Author: thomasjpfan@gmail.com
File Name: examples/classification/plot_digits_classification.py
Class Name:
Method Name: