Skip to content
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

feat: add ai translations as a translation provider #544

Merged
merged 7 commits into from
Dec 19, 2024
18 changes: 18 additions & 0 deletions edxval/migrations/0004_add_edx_ai_translations_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.16 on 2024-11-27 17:14

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('edxval', '0003_delete_transcriptcredentials'),
]

operations = [
migrations.AlterField(
model_name='videotranscript',
name='provider',
field=models.CharField(choices=[('Custom', 'Custom'), ('3PlayMedia', '3PlayMedia'), ('Cielo24', 'Cielo24'), ('edx_ai_translations', 'edx_ai_translations')], default='Custom', max_length=30),
),
]
9 changes: 8 additions & 1 deletion edxval/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,20 @@ class for providing tuple choices.
CUSTOM = 'Custom'
THREE_PLAY_MEDIA = '3PlayMedia'
CIELO24 = 'Cielo24'
EDX_AI_TRANSLATIONS = 'edx_ai_translations'

CHOICES = (
(CUSTOM, CUSTOM),
(THREE_PLAY_MEDIA, THREE_PLAY_MEDIA),
(CIELO24, CIELO24),
)

# Choices specififcally for only the VideoTranscript model
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the CHOICES enumeration already isolated to the VideoTranscript model?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TranscriptPreference and ThirdPartyTranscriptCredentialsState also use this model

TRANSCRIPT_MODEL_CHOICES = (
*CHOICES,
(EDX_AI_TRANSLATIONS, EDX_AI_TRANSLATIONS),
)


class CustomizableFileField(models.FileField):
"""
Expand Down Expand Up @@ -425,7 +432,7 @@ class VideoTranscript(TimeStampedModel):
language_code = models.CharField(max_length=50, db_index=True)
provider = models.CharField(
max_length=30,
choices=TranscriptProviderType.CHOICES,
choices=TranscriptProviderType.TRANSCRIPT_MODEL_CHOICES,
default=TranscriptProviderType.CUSTOM,
)
file_format = models.CharField(max_length=20, db_index=True, choices=TranscriptFormat.CHOICES)
Expand Down
2 changes: 1 addition & 1 deletion edxval/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ def test_update_existing_transcript(self):
'file_format': TranscriptFormat.SRT
},
'message': '"xyz" provider is not supported. Supported transcription providers are "{}"'.format(
sorted(dict(TranscriptProviderType.CHOICES).keys())
sorted(dict(TranscriptProviderType.TRANSCRIPT_MODEL_CHOICES).keys())
)
},
)
Expand Down
2 changes: 1 addition & 1 deletion edxval/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def post(self, request):
).format(format=file_format, supported_formats=supported_formats)
return Response(status=status.HTTP_400_BAD_REQUEST, data={'message': message})

supported_providers = sorted(dict(TranscriptProviderType.CHOICES).keys())
supported_providers = sorted(dict(TranscriptProviderType.TRANSCRIPT_MODEL_CHOICES).keys())
if provider not in supported_providers:
message = (
'"{provider}" provider is not supported. Supported transcription providers are "{supported_providers}"'
Expand Down