-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
FBurkhardt
committed
Nov 5, 2024
1 parent
2cde386
commit 5d0acb5
Showing
7 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""" | ||
A predictor for sid - Speaker ID. | ||
""" | ||
|
||
from pyannote.audio import Pipeline | ||
|
||
|
||
import numpy as np | ||
|
||
import nkululeko.glob_conf as glob_conf | ||
from nkululeko.feature_extractor import FeatureExtractor | ||
from nkululeko.utils.util import Util | ||
|
||
|
||
class SIDPredictor: | ||
"""SIDPredictor. | ||
predicting speaker id. | ||
""" | ||
|
||
def __init__(self, df): | ||
self.df = df | ||
self.util = Util("sidPredictor") | ||
self.pipeline = Pipeline.from_pretrained( | ||
"pyannote/speaker-diarization-3.1", | ||
use_auth_token="HUGGINGFACE_ACCESS_TOKEN_GOES_HERE", | ||
) | ||
|
||
def predict(self, split_selection): | ||
self.util.debug(f"estimating PESQ for {split_selection} samples") | ||
return_df = self.df.copy() | ||
feats_name = "_".join(ast.literal_eval(glob_conf.config["DATA"]["databases"])) | ||
self.feature_extractor = FeatureExtractor( | ||
self.df, ["squim"], feats_name, split_selection | ||
) | ||
result_df = self.feature_extractor.extract() | ||
# replace missing values by 0 | ||
result_df = result_df.fillna(0) | ||
result_df = result_df.replace(np.nan, 0) | ||
result_df.replace([np.inf, -np.inf], 0, inplace=True) | ||
pred_vals = result_df.pesq * 100 | ||
return_df["pesq_pred"] = pred_vals.astype("int") / 100 | ||
return return_df |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
VERSION="0.91.2" | ||
VERSION="0.91.3" | ||
SAMPLING_RATE = 16000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters