From b6bfd054854888f196745ec15872a2157e414947 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 19 May 2021 10:02:53 +0900 Subject: [PATCH] Update repository for speech to text --- backend/api/views/download/factory.py | 2 +- backend/api/views/download/repositories.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/api/views/download/factory.py b/backend/api/views/download/factory.py index e99b9c98..872ea0f1 100644 --- a/backend/api/views/download/factory.py +++ b/backend/api/views/download/factory.py @@ -11,7 +11,7 @@ def create_repository(project) -> repositories.BaseRepository: SEQUENCE_LABELING: repositories.SequenceLabelingRepository, SEQ2SEQ: repositories.Seq2seqRepository, IMAGE_CLASSIFICATION: repositories.FileRepository, - SPEECH2TEXT: repositories.FileRepository, + SPEECH2TEXT: repositories.Speech2TextRepository, } if project.project_type not in mapping: ValueError(f'Invalid project type: {project.project_type}') diff --git a/backend/api/views/download/repositories.py b/backend/api/views/download/repositories.py index 0e139b89..2ac88aa8 100644 --- a/backend/api/views/download/repositories.py +++ b/backend/api/views/download/repositories.py @@ -62,6 +62,15 @@ class FileRepository(BaseRepository): return {'all': value} +class Speech2TextRepository(FileRepository): + + def label_per_user(self, example) -> Dict: + label_per_user = defaultdict(list) + for a in example.texts.all(): + label_per_user[a.user.username].append(a.text) + return label_per_user + + class TextRepository(BaseRepository): @property