Skip to main content

Wagtail Transcription

wagtail-transcription is app for Wagtail that allows to create transcriptions for YouTube videos automatically with just few clicks! To create transcription it use AssemblyAi API.

transcription_gif

Standard Installation

pip install wagtail-transcription

Installation For Developement

If you want to install wagtail-transcription to develop it clone this repository to your project. After that run

pip install -e path_to_wagtail_transcription_core_folder

This will create folder (inside your env lib directory) with json file storing path to wagtail-transcription package. Later setps are the same.

After installation add wagtail_transcription and notifications to your installed apps: Note: Make sure that 'wagtail_transcription' is added before 'wagtail.admin'. Otherwise, administration page will not work properly

INSTALLED_APPS = [
    ...
    'wagtail_transcription',
	'notifications',
	...
]

SetUp

1. Run migrations

After installing wagtail-transcription and adding it to installed apps run migrations:

python manage.py migrate
2. Add wagtail-transcription urls

Add following to your project urls.py

from django.urls import include, path, re_path
from wagtail_transcription import urls as wagtail_transcription_url
import notifications.urls

urlpatterns = [
	...
    path("wagtail_transcription/", include(wagtail_transcription_url)),
    re_path(r'^inbox/notifications/', include(notifications.urls, namespace='notifications')),
	...
]
3. Add ASSEMBLY_API_TOKEN

In your settigns file add 'ASSEMBLY_API_TOKEN' (to get it create Assembly Ai account)

ASSEMBLY_API_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
4. Add YouTube Data API token

In your settings file add YOUTUBE_DATA_API_KEY. To create one check official documentation.

YOUTUBE_DATA_API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
5. Forward your localhost (developement)

IMPORTANT After transcription process ends AssemblyAi will send request to one of wagtail-transcription views. To receive it on local server you have to forward your localhost. Best and easiest option is use tunelling service like localltunnel.

6. Add BASE_URL

In your settings file add 'BASE_URL = "base_url"' this is used when sending webhook_url for AssemblyAi. In developement you should set it to forward url. If you use localltunnel it will be something like this 'https://your_subdomain.loca.lt'

BASE_URL = "base_url"
7. Add DOCUMENTS_GROUP (Optional)

In your settings file add 'DOCUMENTS_GROUP = True' to create menu group from wagtail documents and transcription

DOCUMENTS_GROUP = True

Usage

In model that you want to add dynamically generated transcryption

from wagtail_transcription.edit_handlers import VideoTranscriptionPanel
from wagtail_transcription.models import Transcription

class YourModel(Orderable, models.Model):
    video_id = models.CharField(max_length=255, blank=True)
    transcription = models.ForeignKey(
        Transcription,
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    panels = [
        MultiFieldPanel([
            VideoTranscriptionPanel('video_id', transcription_field='transcription'),
            FieldPanel('transcription'),
        ], heading="Video and Transcription"),
    ]

video_id field accept only youtube video id (not urls).
VideoTranscriptionPanel takes five arguments:

  • field_name - name of field for video_id
  • transcription_field - name of transcription field
  • custom_class - class of transcription widget
  • custom_css - custom css that will be loaded with transcritpion widget
  • custom_js - custom js that will be loaded with transcritpion widget

IMPORTANT You can only generate a transcript on an existing object, if you try to do this in page creation view you will get an error.

Customization

To be more comfortable with customization checkout AssemblyAi Docs

Add custom Transcription Widget class, css and js

In your VideoTranscriptionPanel add

VideoTranscriptionPanel('video_id', transcription_field='transcription', custom_class='custom_transcription', custom_css='app_name/css/custom_transcription.css', custom_js='app_name/js/custom_transcription.js'),

Add custom RequestTranscriptionView

In your settings add

REQUEST_TRANSCRIPTION_VIEW = "app_name.module_name.YourRequestTranscriptionView"

You can easily overwrite how request to AssemblyAi is send by overwriteing request_audio_transcription method

from wagtail_transcription.views import RequestTranscriptionView
class YourRequestTranscriptionView(RequestTranscriptionView):

    def request_audio_transcription(self, audio_url, webhook_url):
        """
		Your awesome request logic
		"""
        return response

Add custom ReceiveTranscriptionView

In your settings add

RECEIVE_TRANSCRIPTION_VIEW = "app_name.module_name.YourReceiveTranscriptionView"

Now you can easily overwrite how request with transcription is processed

from wagtail_transcription.views import ReceiveTranscriptionView

class YourReceiveTranscriptionView(ReceiveTranscriptionView):

    def process_transcription_response(self, transcription_response, 	video_id, model_instance_str, field_name, transcription_field):
        """
        transcription_response - AssemblyAi response with transcription data 
        video_id - id of youtube video for which transcription was made
        model_instance_str - string that allow to get model instance "app:model_name:instance_id"
        field_name = name of field with video_id
        transcription_field = name of field for transcription
        """
        ...
		Your transcription processing logic here
		...
		super().process_transcription_response(transcription_response, 	video_id, model_instance_str, field_name, transcription_field)

Metadata

Release files for wagtail-transcription 0.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtail-transcription 0.0.16
File Size Uploaded Provenance Actions
wagtail-transcription-0.0.16.tar.gz 26.2 kB Without provenance Details for wagtail-transcription-0.0.16.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-transcription 0.0.16
File Interpreter ABI Platform Actions
wagtail_transcription-0.0.16-py3-none-any.whl Python 3 none any Details for wagtail_transcription-0.0.16-py3-none-any.whl

Total release size: 64.1 kB

Release files / wagtail-transcription-0.0.16.tar.gz

Download URL wagtail-transcription-0.0.16.tar.gz
Size 26.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6a8db0f7c27f3b3684865279a778af4f3faaa73292f28d201b5133d1dd2efcf1
BLAKE2b-256 checksum
How to use checksums
5b3b3c8a059a69d7b717eca895d4a11498116e7054b487e2f097782c25b29b4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.2

Release files / wagtail_transcription-0.0.16-py3-none-any.whl

Download URL wagtail_transcription-0.0.16-py3-none-any.whl
Size 37.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
196a7a8f23f3e3944d36e7935ca5c296fde5e022562a3f3daed3ffb7fbead66d
BLAKE2b-256 checksum
How to use checksums
ec3ed53291342f403bc2a6a5a95e7d9d417ec9951d5ad7319a660fcae5674933
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.2

Security for wagtail-transcription 0.0.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page