Skip to content

Commit

Permalink
Differentiate the instantiation of Speech Single-label & Speech Multi…
Browse files Browse the repository at this point in the history
…-label
  • Loading branch information
sabilmakbar committed Nov 15, 2023
1 parent cab228b commit 53e22e2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
8 changes: 6 additions & 2 deletions seacrowd/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
ssp_features,
speech_text_features,
speech2speech_features,
speech_multi_features,
speech_class_features,
speech_multilabel_features,
image_text_features,
)

Expand Down Expand Up @@ -80,6 +81,7 @@ class Tasks(Enum):
SPEECH_RECOGNITION = "ASR"
SPEECH_TO_TEXT_TRANSLATION = "STTT"
SPEECH_TO_TEXT_CLASSIFICATION = "STTC"
SPEECH_TO_TEXT_MULTILABEL = "STTM"
TEXT_TO_SPEECH = "TTS"

# SpeechSpeech
Expand Down Expand Up @@ -208,6 +210,7 @@ class Licenses(Enum):
Tasks.TEXT_TO_SPEECH: "SPTEXT",
Tasks.SPEECH_TO_SPEECH_TRANSLATION: "S2S",
Tasks.SPEECH_TO_TEXT_CLASSIFICATION: "SC",
Tasks.SPEECH_TO_TEXT_MULTILABEL: "SCM",
Tasks.IMAGE_CAPTIONING: "IMTEXT",
Tasks.STYLIZED_IMAGE_CAPTIONING: "IMTEXT",
Tasks.VISUALLY_GROUNDED_REASONING: "IMTEXT",
Expand Down Expand Up @@ -237,7 +240,8 @@ class Licenses(Enum):
"SSP": ssp_features,
"SPTEXT": speech_text_features,
"S2S": speech2speech_features,
"SC": speech_multi_features(),
"SC": speech_class_features(),
"SCM": speech_multilabel_features(),
"IMTEXT": image_text_features(),
}

Expand Down
5 changes: 3 additions & 2 deletions seacrowd/utils/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from .self_supervised_pretraining import features as ssp_features
from .speech_text import features as speech_text_features
from .speech_to_speech import features as speech2speech_features
from .speech_classification import features as speech_multi_features
from .speech_classification import features as speech_class_features
from .speech_multilabel import features as speech_multilabel_features
from .image_text import features as image_text_features

__all__ = ["kb_features", "qa_features", "text2text_features", "text_features", "text_multi_features", "pairs_features", "pairs_multi_features", "pairs_features_score", "seq_label_features", "ssp_features", "speech_text_features", "speech2speech_features", "speech_multi_features", "image_text_features"]
__all__ = ["kb_features", "qa_features", "text2text_features", "text_features", "text_multi_features", "pairs_features", "pairs_multi_features", "pairs_features_score", "seq_label_features", "ssp_features", "speech_text_features", "speech2speech_features", "speech_class_features", "speech_multilabel_features", "image_text_features"]
5 changes: 2 additions & 3 deletions seacrowd/utils/schemas/speech_classification.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Speech Classification Schema (Speech to Label, be it binary or multiclass)
Speech Classification Schema for Single Label (be it Binary or Multiclass)
"""
import datasets

Expand All @@ -9,9 +9,8 @@ def features(label_names = ["Yes", "No"]):
"id": datasets.Value("string"),
"path": datasets.Value("string"),
"audio": datasets.Audio(sampling_rate=16_000),
"text": datasets.Value("string"),
"speaker_id": datasets.Value("string"),
"labels": datasets.Sequence(datasets.ClassLabel(names=label_names)),
"labels": datasets.ClassLabel(names=label_names),
"metadata": {
"speaker_age": datasets.Value("int64"),
"speaker_gender": datasets.Value("string"),
Expand Down
19 changes: 19 additions & 0 deletions seacrowd/utils/schemas/speech_multilabel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Speech Classification Schema for Multilabel
"""
import datasets

def features(label_names = ["Yes", "No"]):
return datasets.Features(
{
"id": datasets.Value("string"),
"path": datasets.Value("string"),
"audio": datasets.Audio(sampling_rate=16_000),
"speaker_id": datasets.Value("string"),
"labels": datasets.Sequence(datasets.ClassLabel(names=label_names)),
"metadata": {
"speaker_age": datasets.Value("int64"),
"speaker_gender": datasets.Value("string"),
}
}
)

0 comments on commit 53e22e2

Please sign in to comment.