File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -284,21 +284,27 @@ Obtain overlap-aware speaker embeddings from a microphone stream:
284
284
``` python
285
285
import rx.operators as ops
286
286
import diart.operators as dops
287
- from diart.sources import MicrophoneAudioSource
287
+ from diart.sources import MicrophoneAudioSource, FileAudioSource
288
288
from diart.blocks import SpeakerSegmentation, OverlapAwareSpeakerEmbedding
289
289
290
290
segmentation = SpeakerSegmentation.from_pretrained(" pyannote/segmentation" )
291
291
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)
293
299
294
300
stream = mic.stream.pipe(
295
301
# 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),
297
303
ops.map(lambda wav : (wav, segmentation(wav))),
298
304
ops.starmap(embedding)
299
305
).subscribe(on_next = lambda emb : print (emb.shape))
300
306
301
- mic .read()
307
+ source .read()
302
308
```
303
309
304
310
Output:
You can’t perform that action at this time.
0 commit comments