Skip to content

Commit 0a4febd

Browse files
hmehdi515juanmc2005
andcommitted
Fix embedding extraction example in README (#241)
* Updated readme embed-extraction pipeline * Updated readme embed-extraction pipeline * Update README.md * Apply suggestions from code review * Update README.md * Update README.md --------- Co-authored-by: Juan Coria <juanmc2005@hotmail.com>
1 parent b44454f commit 0a4febd

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

README.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -284,21 +284,27 @@ Obtain overlap-aware speaker embeddings from a microphone stream:
284284
```python
285285
import rx.operators as ops
286286
import diart.operators as dops
287-
from diart.sources import MicrophoneAudioSource
287+
from diart.sources import MicrophoneAudioSource, FileAudioSource
288288
from diart.blocks import SpeakerSegmentation, OverlapAwareSpeakerEmbedding
289289

290290
segmentation = SpeakerSegmentation.from_pretrained("pyannote/segmentation")
291291
embedding = OverlapAwareSpeakerEmbedding.from_pretrained("pyannote/embedding")
292-
mic = MicrophoneAudioSource()
292+
293+
source = MicrophoneAudioSource()
294+
# To take input from file:
295+
# source = FileAudioSource("<filename>", sample_rate=16000)
296+
297+
# Make sure the models have been trained with this sample rate
298+
print(source.sample_rate)
293299

294300
stream = mic.stream.pipe(
295301
# Reformat stream to 5s duration and 500ms shift
296-
dops.rearrange_audio_stream(sample_rate=segmentation.model.sample_rate),
302+
dops.rearrange_audio_stream(sample_rate=source.sample_rate),
297303
ops.map(lambda wav: (wav, segmentation(wav))),
298304
ops.starmap(embedding)
299305
).subscribe(on_next=lambda emb: print(emb.shape))
300306

301-
mic.read()
307+
source.read()
302308
```
303309

304310
Output:

0 commit comments

Comments
 (0)