Browse Source

Update repository for speech to text

pull/1395/head
Hironsan 3 years ago
parent
commit
b6bfd05485
2 changed files with 10 additions and 1 deletions
  1. 2
      backend/api/views/download/factory.py
  2. 9
      backend/api/views/download/repositories.py

2
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}')

9
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

Loading…
Cancel
Save