Update README.md
Browse files
README.md
CHANGED
|
@@ -32,13 +32,16 @@ The model is fine-tuned on the [LibriMix dataset](https://github.com/JorisCos/Li
|
|
| 32 |
from transformers import Wav2Vec2FeatureExtractor, UniSpeechSatForAudioFrameClassification
|
| 33 |
from datasets import load_dataset
|
| 34 |
import torch
|
|
|
|
| 35 |
dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", split="validation")
|
| 36 |
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained('microsoft/wavlm-base-sd')
|
| 37 |
model = UniSpeechSatForAudioFrameClassification.from_pretrained('microsoft/wavlm-base-sd')
|
|
|
|
| 38 |
# audio file is decoded on the fly
|
| 39 |
inputs = feature_extractor(dataset[0]["audio"]["array"], return_tensors="pt")
|
| 40 |
logits = model(**inputs).logits
|
| 41 |
probabilities = torch.sigmoid(logits[0])
|
|
|
|
| 42 |
# labels is a one-hot array of shape (num_frames, num_speakers)
|
| 43 |
labels = (probabilities > 0.5).long()
|
| 44 |
```
|
|
|
|
| 32 |
from transformers import Wav2Vec2FeatureExtractor, UniSpeechSatForAudioFrameClassification
|
| 33 |
from datasets import load_dataset
|
| 34 |
import torch
|
| 35 |
+
|
| 36 |
dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", split="validation")
|
| 37 |
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained('microsoft/wavlm-base-sd')
|
| 38 |
model = UniSpeechSatForAudioFrameClassification.from_pretrained('microsoft/wavlm-base-sd')
|
| 39 |
+
|
| 40 |
# audio file is decoded on the fly
|
| 41 |
inputs = feature_extractor(dataset[0]["audio"]["array"], return_tensors="pt")
|
| 42 |
logits = model(**inputs).logits
|
| 43 |
probabilities = torch.sigmoid(logits[0])
|
| 44 |
+
|
| 45 |
# labels is a one-hot array of shape (num_frames, num_speakers)
|
| 46 |
labels = (probabilities > 0.5).long()
|
| 47 |
```
|