Spaces:
Running
Running
jhj0517
commited on
Commit
·
8b360a1
1
Parent(s):
d416f9e
disable redundant torchvision warning message
Browse files
modules/diarize/diarize_pipeline.py
CHANGED
|
@@ -1,10 +1,14 @@
|
|
| 1 |
import numpy as np
|
| 2 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
| 3 |
from pyannote.audio import Pipeline
|
|
|
|
| 4 |
from typing import Optional, Union
|
| 5 |
import torch
|
| 6 |
-
|
| 7 |
-
import
|
| 8 |
|
| 9 |
|
| 10 |
class DiarizationPipeline:
|
|
@@ -25,10 +29,10 @@ class DiarizationPipeline:
|
|
| 25 |
|
| 26 |
def __call__(self, audio: Union[str, np.ndarray], min_speakers=None, max_speakers=None):
|
| 27 |
if isinstance(audio, str):
|
| 28 |
-
audio =
|
| 29 |
audio_data = {
|
| 30 |
'waveform': torch.from_numpy(audio[None, :]),
|
| 31 |
-
'sample_rate':
|
| 32 |
}
|
| 33 |
segments = self.model(audio_data, min_speakers=min_speakers, max_speakers=max_speakers)
|
| 34 |
diarize_df = pd.DataFrame(segments.itertracks(yield_label=True), columns=['segment', 'label', 'speaker'])
|
|
|
|
| 1 |
import numpy as np
|
| 2 |
import pandas as pd
|
| 3 |
+
import sys
|
| 4 |
+
import os
|
| 5 |
+
sys.stderr = open(os.devnull, 'w')
|
| 6 |
from pyannote.audio import Pipeline
|
| 7 |
+
sys.stderr.close()
|
| 8 |
from typing import Optional, Union
|
| 9 |
import torch
|
| 10 |
+
|
| 11 |
+
from modules.diarize.audio_loader import load_audio, SAMPLE_RATE
|
| 12 |
|
| 13 |
|
| 14 |
class DiarizationPipeline:
|
|
|
|
| 29 |
|
| 30 |
def __call__(self, audio: Union[str, np.ndarray], min_speakers=None, max_speakers=None):
|
| 31 |
if isinstance(audio, str):
|
| 32 |
+
audio = load_audio(audio)
|
| 33 |
audio_data = {
|
| 34 |
'waveform': torch.from_numpy(audio[None, :]),
|
| 35 |
+
'sample_rate': SAMPLE_RATE
|
| 36 |
}
|
| 37 |
segments = self.model(audio_data, min_speakers=min_speakers, max_speakers=max_speakers)
|
| 38 |
diarize_df = pd.DataFrame(segments.itertracks(yield_label=True), columns=['segment', 'label', 'speaker'])
|