-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
akash5100
wants to merge
264
commits into
learningequality:gsoc/transcription
Choose a base branch
from
akash5100:caption_model
base: gsoc/transcription
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 250 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] 99d27bb
Bump fonttools from 4.27.1 to 4.40.0
dependabot[bot] 1492b09
Bump workbox-precaching from 6.5.4 to 7.0.0
dependabot[bot] ad33170
created captionviewset
akash5100 4f0389e
Adds captions modal with visibility controlled by featureflag
akash5100 d672201
Adds Sync API tests for CaptionFile ViewSet
akash5100 9aa7ac5
Removes unnecessary imports
akash5100 df961f0
Fixes text formatting
akash5100 551c1ad
Creating CaptionCue with generate_create_event fails
akash5100 6bfd927
Add failing test for CaptionFile JSON serialization
akash5100 9c69777
Adds caption editor components, updated IndexedDB Resource
akash5100 c94a30b
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 2719704
Adds KIND check to upload Caption file
akash5100 5bde281
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 41d51a3
Refactor dispatch actions
akash5100 6b7c456
fix linting errors
akash5100 93602b7
Refactor actions dispatch and create Vuex state mapping
akash5100 fe278e2
Stage changes before rebase
akash5100 31ca620
Refactor constants and integrate with Vue comp.
akash5100 d8a65e6
Merge branch 'caption_model' of github.com:akash5100/studio into capt…
akash5100 a31895d
maybe this will break the
akash5100 4f88131
fixs merge conflict
akash5100 c6a5272
created captionviewset
akash5100 73a0882
Adds captions modal with visibility controlled by featureflag
akash5100 471814d
Adds Sync API tests for CaptionFile ViewSet
akash5100 833c1bb
Removes unnecessary imports
akash5100 215f9c0
Fixes text formatting
akash5100 c34e7a9
Creating CaptionCue with generate_create_event fails
akash5100 a6d1840
Add failing test for CaptionFile JSON serialization
akash5100 b102490
Adds caption editor components, updated IndexedDB Resource
akash5100 78f1fdb
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 7beffae
Adds KIND check to upload Caption file
akash5100 afd1093
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 6232c0f
Refactor dispatch actions
akash5100 9728e84
fix linting errors
akash5100 bd0e267
Refactor actions dispatch and create Vuex state mapping
akash5100 099963a
Stage changes before rebase
akash5100 5f402a9
Refactor constants and integrate with Vue comp.
akash5100 4c661ee
created captionviewset
akash5100 e34a98c
Adds captions modal with visibility controlled by featureflag
akash5100 b1c0bbe
Adds Sync API tests for CaptionFile ViewSet
akash5100 6c89366
Removes unnecessary imports
akash5100 ca79d44
Creating CaptionCue with generate_create_event fails
akash5100 00b5812
Adds caption editor components, updated IndexedDB Resource
akash5100 14983f2
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 e2eb875
Adds KIND check to upload Caption file
akash5100 be113f6
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 7f11027
Refactor dispatch actions
akash5100 6e8490e
fix linting errors
akash5100 5625401
Refactor actions dispatch and create Vuex state mapping
akash5100 28a27f7
maybe this will break the
akash5100 76b80f0
fixs merge conflict
akash5100 24b7576
adds dexie livequery and create changes in celery task
akash5100 fa47779
Merge branch 'caption_model' of github.com:akash5100/studio into capt…
akash5100 0c892a8
fix merge conflict
akash5100 2fe1f43
Revert "fix merge conflict"
akash5100 848895e
fix merge conflict
akash5100 a1dc9c6
created captionviewset
akash5100 c85c245
Adds captions modal with visibility controlled by featureflag
akash5100 14996d4
Adds Sync API tests for CaptionFile ViewSet
akash5100 a75ff84
Removes unnecessary imports
akash5100 ab08b66
Fixes text formatting
akash5100 8bebd48
Creating CaptionCue with generate_create_event fails
akash5100 59cbd57
Add failing test for CaptionFile JSON serialization
akash5100 6c08e8e
Adds caption editor components, updated IndexedDB Resource
akash5100 fce1fe0
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 c448bbd
Adds KIND check to upload Caption file
akash5100 e05e8d0
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 e341476
Refactor dispatch actions
akash5100 033517f
fix linting errors
akash5100 57ddc9c
Refactor actions dispatch and create Vuex state mapping
akash5100 52f7a20
Stage changes before rebase
akash5100 9e98ae7
Refactor constants and integrate with Vue comp.
akash5100 1ca1aa7
created captionviewset
akash5100 e7d2139
Adds captions modal with visibility controlled by featureflag
akash5100 4467629
Adds Sync API tests for CaptionFile ViewSet
akash5100 e5805be
Removes unnecessary imports
akash5100 78df2e9
Creating CaptionCue with generate_create_event fails
akash5100 57c9684
Adds caption editor components, updated IndexedDB Resource
akash5100 66db50a
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 e5d4585
Adds KIND check to upload Caption file
akash5100 b4a45c0
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 e29008a
Refactor dispatch actions
akash5100 1a23cc7
fix linting errors
akash5100 390455a
Refactor actions dispatch and create Vuex state mapping
akash5100 c13fbe8
maybe this will break the
akash5100 fbb4a07
fixs merge conflict
akash5100 20da6b8
adds dexie livequery and create changes in celery task
akash5100 c52db7c
created captionviewset
akash5100 117f0a9
Adds captions modal with visibility controlled by featureflag
akash5100 e5a61eb
Adds Sync API tests for CaptionFile ViewSet
akash5100 49c3c81
Removes unnecessary imports
akash5100 42e1363
Creating CaptionCue with generate_create_event fails
akash5100 6da0cad
Add failing test for CaptionFile JSON serialization
akash5100 312aea1
Adds caption editor components, updated IndexedDB Resource
akash5100 cd7502b
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 026bd28
Adds KIND check to upload Caption file
akash5100 0ca719c
Refactor dispatch actions
akash5100 68a8f93
fix linting errors
akash5100 e3e9f21
Refactor actions dispatch and create Vuex state mapping
akash5100 3787cd5
Stage changes before rebase
akash5100 2138992
Refactor constants and integrate with Vue comp.
akash5100 b64b0ec
created captionviewset
akash5100 64b16ac
Adds captions modal with visibility controlled by featureflag
akash5100 02de497
Adds Sync API tests for CaptionFile ViewSet
akash5100 51e50d4
Removes unnecessary imports
akash5100 ca52dbf
Creating CaptionCue with generate_create_event fails
akash5100 5c2a0d8
Add failing test for CaptionFile JSON serialization
akash5100 695f221
Adds caption editor components, updated IndexedDB Resource
akash5100 ab13fdb
Adds KIND check to upload Caption file
akash5100 aea1035
Refactor dispatch actions
akash5100 890dd18
fix linting errors
akash5100 3e3e7b1
Refactor actions dispatch and create Vuex state mapping
akash5100 57d158b
fixs merge conflict
akash5100 594d3d4
loads captioncue to frontend & Refactor endpoint
akash5100 c26b0e4
Update caption-related components and vuex
akash5100 7a524b2
Merge branch 'caption_model' of github.com:akash5100/studio into capt…
akash5100 8c4b771
Enhance settings and Vue modal
akash5100 3f4f583
created captionviewset
akash5100 f298b1b
Adds captions modal with visibility controlled by featureflag
akash5100 cc80288
Adds Sync API tests for CaptionFile ViewSet
akash5100 044b009
Removes unnecessary imports
akash5100 c7dfbd5
Fixes text formatting
akash5100 c016539
Creating CaptionCue with generate_create_event fails
akash5100 d314a43
Add failing test for CaptionFile JSON serialization
akash5100 9e30487
Adds caption editor components, updated IndexedDB Resource
akash5100 361c376
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 acb9c39
Adds KIND check to upload Caption file
akash5100 2b9c0f4
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 f1d0c33
Refactor dispatch actions
akash5100 e4e4c7e
fix linting errors
akash5100 43ff730
Refactor actions dispatch and create Vuex state mapping
akash5100 69a7b6e
Stage changes before rebase
akash5100 c3a7b32
Refactor constants and integrate with Vue comp.
akash5100 172528e
created captionviewset
akash5100 9665281
Adds captions modal with visibility controlled by featureflag
akash5100 132088c
Adds Sync API tests for CaptionFile ViewSet
akash5100 11145f0
Removes unnecessary imports
akash5100 9877af9
Creating CaptionCue with generate_create_event fails
akash5100 43c598d
Adds caption editor components, updated IndexedDB Resource
akash5100 3715775
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 103a538
Adds KIND check to upload Caption file
akash5100 b1c8203
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 d27a425
Refactor dispatch actions
akash5100 fb5e4a3
fix linting errors
akash5100 3a41e59
Refactor actions dispatch and create Vuex state mapping
akash5100 b317103
maybe this will break the
akash5100 b335a93
fixs merge conflict
akash5100 0900ec8
adds dexie livequery and create changes in celery task
akash5100 e0c1151
created captionviewset
akash5100 728a644
Adds captions modal with visibility controlled by featureflag
akash5100 7c22be8
Adds Sync API tests for CaptionFile ViewSet
akash5100 88b2a6e
Removes unnecessary imports
akash5100 2eb5130
Creating CaptionCue with generate_create_event fails
akash5100 703843d
Add failing test for CaptionFile JSON serialization
akash5100 97e3e3a
Adds caption editor components, updated IndexedDB Resource
akash5100 34548b2
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 e62eae5
Adds KIND check to upload Caption file
akash5100 3d1f204
Refactor dispatch actions
akash5100 6abfc4f
fix linting errors
akash5100 787e2c5
Refactor actions dispatch and create Vuex state mapping
akash5100 d28f140
Stage changes before rebase
akash5100 29f143a
Refactor constants and integrate with Vue comp.
akash5100 9f9fec1
created captionviewset
akash5100 8ab594e
Adds captions modal with visibility controlled by featureflag
akash5100 018e9d8
Adds Sync API tests for CaptionFile ViewSet
akash5100 03488c0
Removes unnecessary imports
akash5100 fac0c76
Creating CaptionCue with generate_create_event fails
akash5100 1c9f0a3
Add failing test for CaptionFile JSON serialization
akash5100 42a4a85
Adds caption editor components, updated IndexedDB Resource
akash5100 6799763
Adds KIND check to upload Caption file
akash5100 dc969fc
Refactor dispatch actions
akash5100 720bc76
fix linting errors
akash5100 a3f421d
Refactor actions dispatch and create Vuex state mapping
akash5100 92ca232
fixs merge conflict
akash5100 a8b77b4
loads captioncue to frontend & Refactor endpoint
akash5100 4af9745
Update caption-related components and vuex
akash5100 f0d2820
created captionviewset
akash5100 f549afc
Adds captions modal with visibility controlled by featureflag
akash5100 aa00e97
Adds Sync API tests for CaptionFile ViewSet
akash5100 2cf3339
Removes unnecessary imports
akash5100 7023f2b
Creating CaptionCue with generate_create_event fails
akash5100 431969f
Adds caption editor components, updated IndexedDB Resource
akash5100 4c2867c
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 9ce6cc6
Adds KIND check to upload Caption file
akash5100 39ea9fa
Refactor dispatch actions
akash5100 af19f5a
fix linting errors
akash5100 1fea111
Refactor actions dispatch and create Vuex state mapping
akash5100 3247560
Stage changes before rebase
akash5100 6cade6a
Refactor constants and integrate with Vue comp.
akash5100 29ac1df
created captionviewset
akash5100 b30c58e
Adds captions modal with visibility controlled by featureflag
akash5100 72af8a2
Adds Sync API tests for CaptionFile ViewSet
akash5100 44c65bd
Removes unnecessary imports
akash5100 4a108d2
Creating CaptionCue with generate_create_event fails
akash5100 86c1709
Adds caption editor components, updated IndexedDB Resource
akash5100 715c3da
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 3c5d394
Adds KIND check to upload Caption file
akash5100 65e5eab
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 b31818c
Refactor dispatch actions
akash5100 f73cd82
fix linting errors
akash5100 ffaa6b8
Refactor actions dispatch and create Vuex state mapping
akash5100 9ae224c
maybe this will break the
akash5100 bcbfd5d
fixs merge conflict
akash5100 a66db71
adds dexie livequery and create changes in celery task
akash5100 e9b2d22
created captionviewset
akash5100 7a548fd
Adds captions modal with visibility controlled by featureflag
akash5100 0e62448
Adds Sync API tests for CaptionFile ViewSet
akash5100 e743136
Removes unnecessary imports
akash5100 84e9e4d
Creating CaptionCue with generate_create_event fails
akash5100 8a66fb3
Adds caption editor components, updated IndexedDB Resource
akash5100 b613760
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 cabd81e
Adds KIND check to upload Caption file
akash5100 06fe752
Adds check for Request Cache and to IndexedDB for fetchCollection
akash5100 ec9c26f
Refactor dispatch actions
akash5100 13c0a96
fix linting errors
akash5100 42c095c
Refactor actions dispatch and create Vuex state mapping
akash5100 a3023ec
Stage changes before rebase
akash5100 f5cc992
Refactor constants and integrate with Vue comp.
akash5100 75c3b0d
created captionviewset
akash5100 f510445
Adds captions modal with visibility controlled by featureflag
akash5100 95b6d1f
Adds Sync API tests for CaptionFile ViewSet
akash5100 44dca19
Removes unnecessary imports
akash5100 a903853
Creating CaptionCue with generate_create_event fails
akash5100 de8bfee
Adds caption editor components, updated IndexedDB Resource
akash5100 250dc5b
Refactor id_attr method for retrieving identifier attribute in delete…
akash5100 0c998d1
Adds KIND check to upload Caption file
akash5100 7fea789
Refactor dispatch actions
akash5100 b428d12
fix linting errors
akash5100 fa67522
Refactor actions dispatch and create Vuex state mapping
akash5100 bd32831
fixs merge conflict
akash5100 3aac258
Enhance settings and Vue modal
akash5100 bd6ef86
rebase and clean
akash5100 039322e
Merge branch 'caption_model' of github.com:akash5100/studio into capt…
akash5100 b397f3d
changes enum to dict
akash5100 4355a03
Merge branch 'unstable' of github.com:learningequality/studio into ca…
akash5100 14109fb
adds transcription adapters and backend
akash5100 06c6d9b
refactor hf pipe to connect method
akash5100 bd831b8
Generates vtt file publishing channel
akash5100 e982829
Link vtt file to CaptionFile model
akash5100 a769660
fix duplication of published vtt files
akash5100 67d20bb
Frontend linting fixes
akash5100 1988531
adds test, remove debugging code -- finetune
akash5100 c9ccae9
fix frontend linting errors
akash5100 729c9be
Fix merge conflicts in requirements file
bjester 8ae7832
Regenerate migration after merge
bjester 9e2ca73
Fix WebVTT timedelta format
akash5100 3491b08
Some code refactor
akash5100 ba63a96
Merge branch 'gsoc/transcription' of github.com:learningequality/stud…
akash5100 1a8cab6
Move duplicate dict's to static JSON file
akash5100 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,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 |
This file contains hidden or 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,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.
This file contains hidden or 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,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" | ||
| }) |
141 changes: 141 additions & 0 deletions
141
contentcuration/contentcuration/constants/transcription_languages.py
This file contains hidden or 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,141 @@ | ||
| # The list of languages is obtained from the Whisper project on GitHub, specifically from the tokenizer module. | ||
| # You can find the complete list of available languages in the tokenizer module: | ||
| # https://github.com/openai/whisper/blob/main/whisper/tokenizer.py | ||
|
|
||
| # The supported languages are stored in the 'LANGUAGES' dictionary in the format of language code and language name. | ||
| # For example, the first element in the 'LANGUAGES' dictionary is ('en', 'english'). | ||
|
|
||
| # To add support for a new model, we also need to update the `supportedLanguageList` array in the frontend TranscriptionLanguages.js file. | ||
| # https://github.com/learningequality/studio/blob/unstable/contentcuration/contentcuration/frontend/shared/leUtils/TranscriptionLanguages.js | ||
|
|
||
| import json | ||
| from typing import List, Dict | ||
|
|
||
| import le_utils.resources as resources | ||
|
|
||
| WHISPER_LANGUAGES = { | ||
| "en": "english", | ||
| "zh": "chinese", | ||
| "de": "german", | ||
| "es": "spanish", | ||
| "ru": "russian", | ||
| "ko": "korean", | ||
| "fr": "french", | ||
| "ja": "japanese", | ||
| "pt": "portuguese", | ||
| "tr": "turkish", | ||
| "pl": "polish", | ||
| "ca": "catalan", | ||
| "nl": "dutch", | ||
| "ar": "arabic", | ||
| "sv": "swedish", | ||
| "it": "italian", | ||
| "id": "indonesian", | ||
| "hi": "hindi", | ||
| "fi": "finnish", | ||
| "vi": "vietnamese", | ||
| "he": "hebrew", | ||
| "uk": "ukrainian", | ||
| "el": "greek", | ||
| "ms": "malay", | ||
| "cs": "czech", | ||
| "ro": "romanian", | ||
| "da": "danish", | ||
| "hu": "hungarian", | ||
| "ta": "tamil", | ||
| "no": "norwegian", | ||
| "th": "thai", | ||
| "ur": "urdu", | ||
| "hr": "croatian", | ||
| "bg": "bulgarian", | ||
| "lt": "lithuanian", | ||
| "la": "latin", | ||
| "mi": "maori", | ||
| "ml": "malayalam", | ||
| "cy": "welsh", | ||
| "sk": "slovak", | ||
| "te": "telugu", | ||
| "fa": "persian", | ||
| "lv": "latvian", | ||
| "bn": "bengali", | ||
| "sr": "serbian", | ||
| "az": "azerbaijani", | ||
| "sl": "slovenian", | ||
| "kn": "kannada", | ||
| "et": "estonian", | ||
| "mk": "macedonian", | ||
| "br": "breton", | ||
| "eu": "basque", | ||
| "is": "icelandic", | ||
| "hy": "armenian", | ||
| "ne": "nepali", | ||
| "mn": "mongolian", | ||
| "bs": "bosnian", | ||
| "kk": "kazakh", | ||
| "sq": "albanian", | ||
| "sw": "swahili", | ||
| "gl": "galician", | ||
| "mr": "marathi", | ||
| "pa": "punjabi", | ||
| "si": "sinhala", | ||
| "km": "khmer", | ||
| "sn": "shona", | ||
| "yo": "yoruba", | ||
| "so": "somali", | ||
| "af": "afrikaans", | ||
| "oc": "occitan", | ||
| "ka": "georgian", | ||
| "be": "belarusian", | ||
| "tg": "tajik", | ||
| "sd": "sindhi", | ||
| "gu": "gujarati", | ||
| "am": "amharic", | ||
| "yi": "yiddish", | ||
| "lo": "lao", | ||
| "uz": "uzbek", | ||
| "fo": "faroese", | ||
| "ht": "haitian creole", | ||
| "ps": "pashto", | ||
| "tk": "turkmen", | ||
| "nn": "nynorsk", | ||
| "mt": "maltese", | ||
| "sa": "sanskrit", | ||
| "lb": "luxembourgish", | ||
| "my": "myanmar", | ||
| "bo": "tibetan", | ||
| "tl": "tagalog", | ||
| "mg": "malagasy", | ||
| "as": "assamese", | ||
| "tt": "tatar", | ||
| "haw": "hawaiian", | ||
| "ln": "lingala", | ||
| "ha": "hausa", | ||
| "ba": "bashkir", | ||
| "jw": "javanese", | ||
| "su": "sundanese", | ||
| } | ||
|
|
||
|
|
||
| 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]: | ||
| """Finds the intersection of Kolibri languages and model languages and returns it.""" | ||
| kolibri_set = set(_load_kolibri_languages()) | ||
| model_set = set(_load_model_languages(languages=WHISPER_LANGUAGES)) | ||
| return list(kolibri_set.intersection(model_set)) | ||
|
|
||
|
|
||
| CAPTIONS_LANGUAGES = create_captions_languages() |
This file contains hidden or 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
148 changes: 148 additions & 0 deletions
148
contentcuration/contentcuration/frontend/channelEdit/components/CaptionsTab/CaptionsTab.vue
This file contains hidden or 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,148 @@ | ||
| <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" | ||
| > | ||
| {{ $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 } 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', 'captionCuesMap']), | ||
| node() { | ||
| return this.getContentNode(this.nodeId); | ||
| }, | ||
| excludedLanguages() { | ||
| // excludeLanguages requires array of ids | ||
| return notSupportedCaptionLanguages.map(l => l.id); | ||
| }, | ||
| isGeneratingCaptions() { | ||
| return this.isGeneratingGetter(this.nodeId); | ||
| }, | ||
| }, | ||
| methods: { | ||
| ...mapActions('caption', ['addCaptionFile']), | ||
| addCaption() { | ||
| const id = uuid4(); | ||
| const fileId = this.getLongestDurationFileId(); | ||
| const language = this.selectedLanguage; | ||
| if (!language && !fileId) return; | ||
|
akash5100 marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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> | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.