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

improve: improve support for pyannote.audio #688

Merged
merged 8 commits into from
Mar 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 33 additions & 9 deletions js/src/lib/interfaces/Libraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export enum ModelLibrary {
"fairseq" = "Fairseq",
"flair" = "Flair",
"keras" = "Keras",
"pyannote" = "Pyannote",
"pyannote-audio" = "pyannote.audio",
"sentence-transformers" = "Sentence Transformers",
"sklearn" = "Scikit-learn",
"spacy" = "spaCy",
Expand Down Expand Up @@ -138,18 +138,42 @@ const keras = (model: ModelData) =>
model = from_pretrained_keras("${model.id}")
`;

const pyannote = (model: ModelData) =>
`from pyannote.audio.core.inference import Inference
const pyannote_audio_pipeline = (model: ModelData) =>
`from pyannote.audio import Pipeline

model = Inference("${model.id}")
pipeline = Pipeline.from_pretrained("${model.id}")

# inference on the whole file
model("file.wav")
pipeline("file.wav")

# inference on an excerpt
from pyannote.core import Segment
excerpt = Segment(start=2.0, end=5.0)
model.crop("file.wav", excerpt)`;

from pyannote.audio import Audio
waveform, sample_rate = Audio().crop("file.wav", excerpt)
pipeline({"waveform": waveform, "sample_rate": sample_rate})`;

const pyannote_audio_model = (model: ModelData) =>
`from pyannote.audio import Model, Inference

model = Model.from_pretrained("${model.id}")
inference = Inference(model)

# inference on the whole file
inference("file.wav")

# inference on an excerpt
from pyannote.core import Segment
excerpt = Segment(start=2.0, end=5.0)
inference.crop("file.wav", excerpt)`;

const pyannote_audio = (model: ModelData) => {
if (model.tags?.includes("pyannote-audio-pipeline")) {
hbredin marked this conversation as resolved.
Show resolved Hide resolved
return pyannote_audio_pipeline(model);
}
return pyannote_audio_model(model);
};

const tensorflowttsTextToMel = (model: ModelData) =>
`from tensorflow_tts.inference import AutoProcessor, TFAutoModel
Expand Down Expand Up @@ -338,11 +362,11 @@ export const MODEL_LIBRARIES_UI_ELEMENTS: { [key in keyof typeof ModelLibrary]?:
repoUrl: "https://github.com/keras-team/keras",
snippet: keras,
},
"pyannote": {
btnLabel: "pyannote",
"pyannote-audio": {
btnLabel: "pyannote.audio",
repoName: "pyannote-audio",
repoUrl: "https://github.com/pyannote/pyannote-audio",
snippet: pyannote,
snippet: pyannote_audio,
},
"sentence-transformers": {
btnLabel: "sentence-transformers",
Expand Down