Skip to content

Add caption support with new models, vuex, and edit modal integration #4151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 264 commits into
base: gsoc/transcription
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
264 commits
Select commit Hold shift + click to select a range
e9ed2e6
Bump semver from 5.7.1 to 5.7.2
dependabot[bot] Jul 10, 2023
99d27bb
Bump fonttools from 4.27.1 to 4.40.0
dependabot[bot] Jun 13, 2023
1492b09
Bump workbox-precaching from 6.5.4 to 7.0.0
dependabot[bot] Jul 13, 2023
ad33170
created captionviewset
akash5100 May 23, 2023
4f0389e
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
d672201
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
9aa7ac5
Removes unnecessary imports
akash5100 Jun 27, 2023
df961f0
Fixes text formatting
akash5100 Jun 27, 2023
551c1ad
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
6bfd927
Add failing test for CaptionFile JSON serialization
akash5100 Jun 30, 2023
9c69777
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
c94a30b
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Jul 11, 2023
2719704
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
5bde281
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 Jul 17, 2023
41d51a3
Refactor dispatch actions
akash5100 Jul 18, 2023
6b7c456
fix linting errors
akash5100 Jul 18, 2023
93602b7
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
fe278e2
Stage changes before rebase
akash5100 Jul 27, 2023
31ca620
Refactor constants and integrate with Vue comp.
akash5100 Aug 1, 2023
d8a65e6
Merge branch 'caption_model' of github.com:akash5100/studio into capt…
akash5100 Aug 1, 2023
a31895d
maybe this will break the
akash5100 Aug 1, 2023
4f88131
fixs merge conflict
akash5100 Aug 1, 2023
c6a5272
created captionviewset
akash5100 May 23, 2023
73a0882
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
471814d
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
833c1bb
Removes unnecessary imports
akash5100 Jun 27, 2023
215f9c0
Fixes text formatting
akash5100 Jun 27, 2023
c34e7a9
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
a6d1840
Add failing test for CaptionFile JSON serialization
akash5100 Jun 30, 2023
b102490
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
78f1fdb
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Jul 11, 2023
7beffae
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
afd1093
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 Jul 17, 2023
6232c0f
Refactor dispatch actions
akash5100 Jul 18, 2023
9728e84
fix linting errors
akash5100 Jul 18, 2023
bd0e267
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
099963a
Stage changes before rebase
akash5100 Jul 27, 2023
5f402a9
Refactor constants and integrate with Vue comp.
akash5100 Aug 1, 2023
4c661ee
created captionviewset
akash5100 May 23, 2023
e34a98c
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
b1c0bbe
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
6c89366
Removes unnecessary imports
akash5100 Jun 27, 2023
ca79d44
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
00b5812
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
14983f2
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Jul 11, 2023
e2eb875
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
be113f6
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 Jul 17, 2023
7f11027
Refactor dispatch actions
akash5100 Jul 18, 2023
6e8490e
fix linting errors
akash5100 Jul 18, 2023
5625401
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
28a27f7
maybe this will break the
akash5100 Aug 1, 2023
76b80f0
fixs merge conflict
akash5100 Aug 1, 2023
24b7576
adds dexie livequery and create changes in celery task
akash5100 Aug 15, 2023
fa47779
Merge branch 'caption_model' of github.com:akash5100/studio into capt…
akash5100 Aug 15, 2023
0c892a8
fix merge conflict
akash5100 Aug 15, 2023
2fe1f43
Revert "fix merge conflict"
akash5100 Aug 15, 2023
848895e
fix merge conflict
akash5100 Aug 15, 2023
a1dc9c6
created captionviewset
akash5100 May 23, 2023
c85c245
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
14996d4
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
a75ff84
Removes unnecessary imports
akash5100 Jun 27, 2023
ab08b66
Fixes text formatting
akash5100 Jun 27, 2023
8bebd48
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
59cbd57
Add failing test for CaptionFile JSON serialization
akash5100 Jun 30, 2023
6c08e8e
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
fce1fe0
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Jul 11, 2023
c448bbd
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
e05e8d0
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 Jul 17, 2023
e341476
Refactor dispatch actions
akash5100 Jul 18, 2023
033517f
fix linting errors
akash5100 Jul 18, 2023
57ddc9c
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
52f7a20
Stage changes before rebase
akash5100 Jul 27, 2023
9e98ae7
Refactor constants and integrate with Vue comp.
akash5100 Aug 1, 2023
1ca1aa7
created captionviewset
akash5100 May 23, 2023
e7d2139
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
4467629
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
e5805be
Removes unnecessary imports
akash5100 Jun 27, 2023
78df2e9
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
57c9684
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
66db50a
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Jul 11, 2023
e5d4585
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
b4a45c0
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 Jul 17, 2023
e29008a
Refactor dispatch actions
akash5100 Jul 18, 2023
1a23cc7
fix linting errors
akash5100 Jul 18, 2023
390455a
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
c13fbe8
maybe this will break the
akash5100 Aug 1, 2023
fbb4a07
fixs merge conflict
akash5100 Aug 1, 2023
20da6b8
adds dexie livequery and create changes in celery task
akash5100 Aug 15, 2023
c52db7c
created captionviewset
akash5100 May 23, 2023
117f0a9
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
e5a61eb
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
49c3c81
Removes unnecessary imports
akash5100 Jun 27, 2023
42e1363
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
6da0cad
Add failing test for CaptionFile JSON serialization
akash5100 Jun 30, 2023
312aea1
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
cd7502b
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Jul 11, 2023
026bd28
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
0ca719c
Refactor dispatch actions
akash5100 Jul 18, 2023
68a8f93
fix linting errors
akash5100 Jul 18, 2023
e3e9f21
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
3787cd5
Stage changes before rebase
akash5100 Jul 27, 2023
2138992
Refactor constants and integrate with Vue comp.
akash5100 Aug 1, 2023
b64b0ec
created captionviewset
akash5100 May 23, 2023
64b16ac
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
02de497
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
51e50d4
Removes unnecessary imports
akash5100 Jun 27, 2023
ca52dbf
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
5c2a0d8
Add failing test for CaptionFile JSON serialization
akash5100 Jun 30, 2023
695f221
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
ab13fdb
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
aea1035
Refactor dispatch actions
akash5100 Jul 18, 2023
890dd18
fix linting errors
akash5100 Jul 18, 2023
3e3e7b1
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
57d158b
fixs merge conflict
akash5100 Aug 1, 2023
594d3d4
loads captioncue to frontend & Refactor endpoint
akash5100 Aug 17, 2023
c26b0e4
Update caption-related components and vuex
akash5100 Aug 31, 2023
7a524b2
Merge branch 'caption_model' of github.com:akash5100/studio into capt…
akash5100 Aug 31, 2023
8c4b771
Enhance settings and Vue modal
akash5100 Sep 11, 2023
3f4f583
created captionviewset
akash5100 May 23, 2023
f298b1b
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
cc80288
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
044b009
Removes unnecessary imports
akash5100 Jun 27, 2023
c7dfbd5
Fixes text formatting
akash5100 Jun 27, 2023
c016539
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
d314a43
Add failing test for CaptionFile JSON serialization
akash5100 Jun 30, 2023
9e30487
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
361c376
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Jul 11, 2023
acb9c39
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
2b9c0f4
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 Jul 17, 2023
f1d0c33
Refactor dispatch actions
akash5100 Jul 18, 2023
e4e4c7e
fix linting errors
akash5100 Jul 18, 2023
43ff730
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
69a7b6e
Stage changes before rebase
akash5100 Jul 27, 2023
c3a7b32
Refactor constants and integrate with Vue comp.
akash5100 Aug 1, 2023
172528e
created captionviewset
akash5100 May 23, 2023
9665281
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
132088c
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
11145f0
Removes unnecessary imports
akash5100 Jun 27, 2023
9877af9
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
43c598d
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
3715775
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Jul 11, 2023
103a538
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
b1c8203
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 Jul 17, 2023
d27a425
Refactor dispatch actions
akash5100 Jul 18, 2023
fb5e4a3
fix linting errors
akash5100 Jul 18, 2023
3a41e59
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
b317103
maybe this will break the
akash5100 Aug 1, 2023
b335a93
fixs merge conflict
akash5100 Aug 1, 2023
0900ec8
adds dexie livequery and create changes in celery task
akash5100 Aug 15, 2023
e0c1151
created captionviewset
akash5100 May 23, 2023
728a644
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
7c22be8
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
88b2a6e
Removes unnecessary imports
akash5100 Jun 27, 2023
2eb5130
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
703843d
Add failing test for CaptionFile JSON serialization
akash5100 Jun 30, 2023
97e3e3a
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
34548b2
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Jul 11, 2023
e62eae5
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
3d1f204
Refactor dispatch actions
akash5100 Jul 18, 2023
6abfc4f
fix linting errors
akash5100 Jul 18, 2023
787e2c5
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
d28f140
Stage changes before rebase
akash5100 Jul 27, 2023
29f143a
Refactor constants and integrate with Vue comp.
akash5100 Aug 1, 2023
9f9fec1
created captionviewset
akash5100 May 23, 2023
8ab594e
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
018e9d8
Adds Sync API tests for CaptionFile ViewSet
akash5100 Jun 27, 2023
03488c0
Removes unnecessary imports
akash5100 Jun 27, 2023
fac0c76
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
1c9f0a3
Add failing test for CaptionFile JSON serialization
akash5100 Jun 30, 2023
42a4a85
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
6799763
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
dc969fc
Refactor dispatch actions
akash5100 Jul 18, 2023
720bc76
fix linting errors
akash5100 Jul 18, 2023
a3f421d
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
92ca232
fixs merge conflict
akash5100 Aug 1, 2023
a8b77b4
loads captioncue to frontend & Refactor endpoint
akash5100 Aug 17, 2023
4af9745
Update caption-related components and vuex
akash5100 Aug 31, 2023
f0d2820
created captionviewset
akash5100 Sep 23, 2023
f549afc
Adds captions modal with visibility controlled by featureflag
akash5100 Sep 23, 2023
aa00e97
Adds Sync API tests for CaptionFile ViewSet
akash5100 Sep 23, 2023
2cf3339
Removes unnecessary imports
akash5100 Jun 27, 2023
7023f2b
Creating CaptionCue with generate_create_event fails
akash5100 Sep 23, 2023
431969f
Adds caption editor components, updated IndexedDB Resource
akash5100 Sep 23, 2023
4c2867c
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Sep 23, 2023
9ce6cc6
Adds KIND check to upload Caption file
akash5100 Sep 23, 2023
39ea9fa
Refactor dispatch actions
akash5100 Jul 18, 2023
af19f5a
fix linting errors
akash5100 Jul 18, 2023
1fea111
Refactor actions dispatch and create Vuex state mapping
akash5100 Sep 23, 2023
3247560
Stage changes before rebase
akash5100 Sep 23, 2023
6cade6a
Refactor constants and integrate with Vue comp.
akash5100 Sep 23, 2023
29ac1df
created captionviewset
akash5100 May 23, 2023
b30c58e
Adds captions modal with visibility controlled by featureflag
akash5100 Jun 19, 2023
72af8a2
Adds Sync API tests for CaptionFile ViewSet
akash5100 Sep 23, 2023
44c65bd
Removes unnecessary imports
akash5100 Jun 27, 2023
4a108d2
Creating CaptionCue with generate_create_event fails
akash5100 Jun 30, 2023
86c1709
Adds caption editor components, updated IndexedDB Resource
akash5100 Jul 7, 2023
715c3da
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Sep 23, 2023
3c5d394
Adds KIND check to upload Caption file
akash5100 Jul 17, 2023
65e5eab
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 Jul 17, 2023
b31818c
Refactor dispatch actions
akash5100 Jul 18, 2023
f73cd82
fix linting errors
akash5100 Jul 18, 2023
ffaa6b8
Refactor actions dispatch and create Vuex state mapping
akash5100 Jul 25, 2023
9ae224c
maybe this will break the
akash5100 Sep 23, 2023
bcbfd5d
fixs merge conflict
akash5100 Aug 1, 2023
a66db71
adds dexie livequery and create changes in celery task
akash5100 Sep 23, 2023
e9b2d22
created captionviewset
akash5100 Sep 23, 2023
7a548fd
Adds captions modal with visibility controlled by featureflag
akash5100 Sep 23, 2023
0e62448
Adds Sync API tests for CaptionFile ViewSet
akash5100 Sep 23, 2023
e743136
Removes unnecessary imports
akash5100 Jun 27, 2023
84e9e4d
Creating CaptionCue with generate_create_event fails
akash5100 Sep 23, 2023
8a66fb3
Adds caption editor components, updated IndexedDB Resource
akash5100 Sep 23, 2023
b613760
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Sep 23, 2023
cabd81e
Adds KIND check to upload Caption file
akash5100 Sep 23, 2023
06fe752
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 Sep 23, 2023
ec9c26f
Refactor dispatch actions
akash5100 Jul 18, 2023
13c0a96
fix linting errors
akash5100 Sep 23, 2023
42c095c
Refactor actions dispatch and create Vuex state mapping
akash5100 Sep 23, 2023
a3023ec
Stage changes before rebase
akash5100 Sep 23, 2023
f5cc992
Refactor constants and integrate with Vue comp.
akash5100 Sep 23, 2023
75c3b0d
created captionviewset
akash5100 Sep 23, 2023
f510445
Adds captions modal with visibility controlled by featureflag
akash5100 Sep 23, 2023
95b6d1f
Adds Sync API tests for CaptionFile ViewSet
akash5100 Sep 23, 2023
44dca19
Removes unnecessary imports
akash5100 Jun 27, 2023
a903853
Creating CaptionCue with generate_create_event fails
akash5100 Sep 23, 2023
de8bfee
Adds caption editor components, updated IndexedDB Resource
akash5100 Sep 23, 2023
250dc5b
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 Sep 23, 2023
0c998d1
Adds KIND check to upload Caption file
akash5100 Sep 23, 2023
7fea789
Refactor dispatch actions
akash5100 Jul 18, 2023
b428d12
fix linting errors
akash5100 Sep 23, 2023
fa67522
Refactor actions dispatch and create Vuex state mapping
akash5100 Sep 23, 2023
bd32831
fixs merge conflict
akash5100 Sep 23, 2023
3aac258
Enhance settings and Vue modal
akash5100 Sep 23, 2023
bd6ef86
rebase and clean
akash5100 Sep 25, 2023
039322e
Merge branch 'caption_model' of github.com:akash5100/studio into capt…
akash5100 Sep 25, 2023
b397f3d
changes enum to dict
akash5100 Sep 26, 2023
4355a03
Merge branch 'unstable' of github.com:learningequality/studio into ca…
akash5100 Oct 2, 2023
14109fb
adds transcription adapters and backend
akash5100 Oct 4, 2023
06c6d9b
refactor hf pipe to connect method
akash5100 Oct 5, 2023
bd831b8
Generates vtt file publishing channel
akash5100 Oct 14, 2023
e982829
Link vtt file to CaptionFile model
akash5100 Oct 17, 2023
a769660
fix duplication of published vtt files
akash5100 Oct 18, 2023
67d20bb
Frontend linting fixes
akash5100 Oct 18, 2023
1988531
adds test, remove debugging code -- finetune
akash5100 Nov 1, 2023
c9ccae9
fix frontend linting errors
akash5100 Nov 1, 2023
729c9be
Fix merge conflicts in requirements file
bjester Nov 1, 2023
8ae7832
Regenerate migration after merge
bjester Nov 1, 2023
9e2ca73
Fix WebVTT timedelta format
akash5100 Nov 2, 2023
3491b08
Some code refactor
akash5100 Nov 9, 2023
ba63a96
Merge branch 'gsoc/transcription' of github.com:learningequality/stud…
akash5100 Nov 15, 2023
1a8cab6
Move duplicate dict's to static JSON file
akash5100 Nov 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions contentcuration/automation/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from enum import Enum
from torch.cuda import is_available as is_gpu_available

DEVICE = "cuda:0" if is_gpu_available() else "cpu"


# [TRANSCRIPTION GENERATION]
WHISPER_MODELS = dict(
TINY="openai/whisper-tiny",
BASE="openai/whisper-base",
SMALL="openai/whisper-small",
MEDIUM="openai/whisper-medium",
LARGE="openai/whisper-large",
LARGEV2="openai/whisper-large-v2",
)


DEV_TRANSCRIPTION_MODEL = WHISPER_MODELS['TINY']
TRANSCRIPTION_MODEL = WHISPER_MODELS['TINY']

class WhisperTask(Enum):
TRANSLATE = "translate"
TRANSCRIBE = "transcribe"

# https://huggingface.co/docs/transformers/v4.29.1/en/generation_strategies#customize-text-generation
MAX_TOKEN_LENGTH = 448
CHUNK_LENGTH = 10
10 changes: 10 additions & 0 deletions contentcuration/automation/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from automation.views import TranscriptionsViewSet
from django.urls import include, path
from rest_framework import routers

automation_router = routers.DefaultRouter()
automation_router.register(r'transcribe', TranscriptionsViewSet, basename="transcribe")

urlpatterns = [
path("api/automation/", include(automation_router.urls), name='automation'),
]
Empty file.
11 changes: 9 additions & 2 deletions contentcuration/automation/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# from django.shortcuts import render
from rest_framework.viewsets import ViewSet
from rest_framework.response import Response
from rest_framework.permissions import AllowAny

# Create your views here.
class TranscriptionsViewSet(ViewSet):
def create(self, request):
permission_classes = [AllowAny]
return Response({
"OK":"OK"
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# The list of supported AI languages is dynamically loaded from a JSON file.
# You can update the supported languages for transcription by modifying the 'ai_supported_languages.json' file.
# The script then determines the intersection of languages supported by the Kolibri project and the Whisper speech-to-text model.
# The resulting list of language codes is stored in CAPTION_LANGUAGES for creating captions.
# Note: To update supported languages, modify the 'ai_supported_languages.json' file.

import os
import json
from typing import List, Dict

import le_utils.resources as resources


def _ai_supported_languages() -> Dict:
"""Loads JSON of supported AI languages"""
file = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"../static/ai_supported_languages.json",
)
with open(file) as f:
data = json.load(f)
return data


WHISPER_LANGUAGES = _ai_supported_languages()


def _load_kolibri_languages() -> List[str]:
"""Loads the language codes from languagelookup.json and returns them as a list."""
filepath = resources.__path__[0]
kolibri_languages = []
with open(f"{filepath}/languagelookup.json") as f:
kolibri_languages = list(json.load(f).keys())
return kolibri_languages


def _load_model_languages(languages: Dict[str, str]) -> List[str]:
"""Load languages supported by the speech-to-text model.
:param: languages: dict mapping language codes to language names"""
return list(languages.keys())


def create_captions_languages() -> List[str]:
"""Returns the intersection of Kolibri languages and model languages"""
kolibri_set = set(_load_kolibri_languages())
model_set = set(_load_model_languages(languages=WHISPER_LANGUAGES))
return list(kolibri_set.intersection(model_set))


# list of language id's ['en', 'hi', ...]
CAPTION_LANGUAGES = create_captions_languages()
3 changes: 3 additions & 0 deletions contentcuration/contentcuration/dev_urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import urllib.parse

from automation.urls import urlpatterns as automation_urlpatterns
from django.conf import settings
from django.contrib import admin
from django.core.files.storage import default_storage
Expand Down Expand Up @@ -76,6 +77,8 @@ def file_server(request, storage_path=None):
re_path(r"^content/(?P<storage_path>.+)$", file_server),
]

urlpatterns += automation_urlpatterns

if getattr(settings, "DEBUG_PANEL_ACTIVE", False):

import debug_toolbar
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<template>

<div class="captions-tab-section">
<div class="my-4 px-4 title">
<ContentNodeIcon
v-if="node && node.kind"
:kind="node.kind"
class="mr-1"
/>
<h2
v-if="node && node.title"
class="headline mx-2 notranslate"
data-test="title"
>
{{ $tr('header', { fileName: node.title }) }}
</h2>
</div>

<div v-if="!isGeneratingCaptions" class="mb-2 mt-2 px-4">
<p class="my-2">
{{ $tr('captionGenerationHelpText') }}
</p>

<LanguageDropdown
ref="language"
v-model="selectedLanguage"
clearable
:required="true"
:excludeLanguages="excludedLanguages"
/>

<VBtn
v-if="selectedLanguage && !isGeneratingCaptions"
flat
color="primary"
class="font-weight-bold ml-0"
@click="addCaption"
:disabled="isCaptionFileExisting"
>
{{ $tr('generateBtn') }}
</VBtn>
</div>
<!-- TODO -->
<!-- est. time, time elapsed can be good -->
<p v-if="isGeneratingCaptions">
{{ $tr('generating', { fileName: node.title }) }}
<LoadingText />
<br>
</p>

</div>

</template>

<script>

import { mapActions, mapGetters, mapState } from 'vuex';
import { CaptionFile, uuid4 } from 'shared/data/resources';
import { notSupportedCaptionLanguages } from 'shared/leUtils/TranscriptionLanguages';
import ContentNodeIcon from 'shared/views/ContentNodeIcon';
import LoadingText from 'shared/views/LoadingText';
import LanguageDropdown from 'shared/views/LanguageDropdown';

export default {
name: 'CaptionsTab',
components: {
ContentNodeIcon,
LanguageDropdown,
LoadingText,
},
props: {
nodeId: {
type: String,
required: true,
},
},
data() {
return {
selectedLanguage: null,
};
},
computed: {
...mapGetters('contentNode', ['getContentNode']),
...mapGetters('caption', ['isGeneratingGetter']),
...mapGetters('file', ['getContentNodeFiles']),
...mapState('caption', ['captionFilesMap']),
node() {
return this.getContentNode(this.nodeId);
},
excludedLanguages() {
// excludeLanguages requires array of ids
return notSupportedCaptionLanguages.map(l => l.id);
},
isGeneratingCaptions() {
return this.isGeneratingGetter(this.nodeId);
},
isCaptionFileExisting() {
const language = this.selectedLanguage;
const fileId = this.getLongestDurationFileId();
return this.checkExistingFile(this.captionFilesMap[this.nodeId], fileId, language)
}
},
methods: {
...mapActions('caption', ['addCaptionFile']),
checkExistingFile(captionFilesMap, captionFileId, language) {
if(!captionFilesMap) return false;
return Object.values(captionFilesMap).some(file => {
return file.file_id === captionFileId && file.language === language;
})
},
addCaption() {
const id = uuid4();
const fileId = this.getLongestDurationFileId();
const language = this.selectedLanguage;
if (!language || !fileId) return;
const fileExists = this.checkExistingFile(
this.captionFilesMap[this.nodeId], fileId, language);
if(fileExists) return;
this.addCaptionFile({
id: id,
file_id: fileId,
language: language,
nodeId: this.nodeId,
});

CaptionFile.waitForCaptionCueGeneration(id).then(() => {
this.selectedLanguage = null;
});
},
getLongestDurationFileId() {
const files = this.getContentNodeFiles(this.nodeId);
const { id } = files.reduce((max, file) => (file.duration > max.duration ? file : max), {
duration: 0,
});
return id;
},
},
$trs: {
header: 'Add Captions for {fileName}',
generateBtn: 'Generate Captions',
captionGenerationHelpText:
'Select a language to automatically generate captions for this video',
generating: 'Generating caption for file: {fileName}',
},
};

</script>

<style lang="less" scoped>

.captions-tab-section {
height: 80vh;
vertical-align: text-top;
}

.title {
display: inline-flex;
align-items: center;
justify-content: flex-start;
}

</style>
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
// (especially marking nodes as (in)complete)
vm.loadFiles({ contentnode__in: childrenNodesIds }),
vm.loadAssessmentItems({ contentnode__in: childrenNodesIds }),
vm.loadCaptions({ contentnode__in: childrenNodesIds }),
];
} else {
// no need to load assessment items or files as topics have none
Expand Down Expand Up @@ -394,6 +395,7 @@
]),
...mapActions('file', ['loadFiles', 'updateFile']),
...mapActions('assessmentItem', ['loadAssessmentItems', 'updateAssessmentItems']),
...mapActions('caption', ['loadCaptions']),
...mapMutations('contentNode', { enableValidation: 'ENABLE_VALIDATION_ON_NODES' }),
closeModal() {
this.promptUploading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@
{{ relatedResourcesCount }}
</VChip>
</VTab>

<!-- Captions editing tab -->
<VTab
v-if="showCaptions"
ref="caption-tab"
:href="`#${tabs.CAPTIONS}`"
@click="trackTab('Captions')"
>
{{ $tr(tabs.CAPTIONS) }}
</VTab>
</Tabs>
</ToolBar>
<VContainer fluid>
Expand All @@ -82,13 +92,19 @@
<VTabItem :key="tabs.QUESTIONS" ref="questionwindow" :value="tabs.QUESTIONS" lazy>
<AssessmentTab :nodeId="nodeIds[0]" />
</VTabItem>

<VTabItem
:key="tabs.RELATED"
:value="tabs.RELATED"
lazy
>
<RelatedResourcesTab :nodeId="nodeIds[0]" />
</VTabItem>

<VTabItem
:key="tabs.CAPTIONS" ref="captionswindow" :value="tabs.CAPTIONS" lazy>
<CaptionsTab :nodeId="nodeIds[0]" />
</VTabItem>
</VTabsItems>
</VContainer>
</VFlex>
Expand All @@ -104,6 +120,7 @@

import { TabNames } from '../../constants';
import AssessmentTab from '../../components/AssessmentTab/AssessmentTab';
import CaptionsTab from '../../components/CaptionsTab/CaptionsTab'
import RelatedResourcesTab from '../../components/RelatedResourcesTab/RelatedResourcesTab';
import DetailsTabView from './DetailsTabView';
import { ContentKindsNames } from 'shared/leUtils/ContentKinds';
Expand All @@ -113,11 +130,12 @@
export default {
name: 'EditView',
components: {
DetailsTabView,
AssessmentTab,
RelatedResourcesTab,
Tabs,
ToolBar,
AssessmentTab,
CaptionsTab,
DetailsTabView,
RelatedResourcesTab,
Tabs,
ToolBar,
},
props: {
nodeIds: {
Expand All @@ -143,6 +161,7 @@
'getImmediateRelatedResourcesCount',
]),
...mapGetters('assessmentItem', ['getAssessmentItemsAreValid', 'getAssessmentItemsCount']),
...mapGetters(['isAIFeatureEnabled']),
firstNode() {
return this.nodes.length ? this.nodes[0] : null;
},
Expand All @@ -167,6 +186,14 @@
showRelatedResourcesTab() {
return this.oneSelected && this.firstNode && this.firstNode.kind !== 'topic';
},
showCaptions() {
return (
this.oneSelected &&
this.firstNode &&
(this.firstNode.kind === 'video' || this.firstNode.kind === 'audio') &&
this.isAIFeatureEnabled
)
},
countText() {
const totals = reduce(
this.nodes,
Expand Down Expand Up @@ -260,6 +287,8 @@
questions: 'Questions',
/** @see TabNames.RELATED */
related: 'Related',
/** @see TabNames.CAPTIONS */
captions: 'Captions',
/* eslint-enable kolibri/vue-no-unused-translations */
noItemsToEditText: 'Please select resources or folders to edit',
invalidFieldsToolTip: 'Some required information is missing',
Expand Down
Loading