wagtail-transcription


Namewagtail-transcription JSON
Version 0.0.16 PyPI version JSON
download
home_pagehttps://github.com/LilJack118/wagtail-transcription
Summary
upload_time2024-03-08 13:15:43
maintainer
docs_urlNone
authorLilJack118
requires_python>=3.9
license
keywords wagtail django
VCS
bugtrack_url
requirements Django wagtail django-notifications-hq python-docx pytube psycopg2
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Wagtail Transcription
[wagtail-transcription](https://pypi.org/project/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](https://www.assemblyai.com/ "AssemblyAi") API.

![transcription_gif](images/transcription_gif.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
```python
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](https://app.assemblyai.com/signup "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](https://developers.google.com/youtube/v3/getting-started "official documentation").

```
YOUTUBE_DATA_API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
```

##### 5. Forward your localhost (developement)
<b style="color:red;">IMPORTANT</b>
After transcription process ends [AssemblyAi](https://www.assemblyai.com/ "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](https://theboroer.github.io/localtunnel-www/ "localltunnel").

##### 6. Add BASE_URL 
In your settings file add '**BASE_URL = "base_url"**' this is used when sending webhook_url for [AssemblyAi](https://www.assemblyai.com/ "AssemblyAi"). In developement you should set it to forward url. If you use [localltunnel](https://theboroer.github.io/localtunnel-www/ "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).<br/>
**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

<b style="color:red;">IMPORTANT</b>
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](https://www.assemblyai.com/docs/ "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)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/LilJack118/wagtail-transcription",
    "name": "wagtail-transcription",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "wagtail django",
    "author": "LilJack118",
    "author_email": "jakub@kachange.com",
    "download_url": "https://files.pythonhosted.org/packages/5b/3b/3c8a059a69d7b717eca895d4a11498116e7054b487e2f097782c25b29b4b/wagtail-transcription-0.0.16.tar.gz",
    "platform": null,
    "description": "# Wagtail Transcription\n[wagtail-transcription](https://pypi.org/project/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](https://www.assemblyai.com/ \"AssemblyAi\") API.\n\n![transcription_gif](images/transcription_gif.gif)\n\n#### Standard Installation\n```\npip install wagtail-transcription\n```\n\n#### Installation For Developement\nIf you want to install wagtail-transcription to develop it clone this repository to your project. After that run\n```python\npip install -e path_to_wagtail_transcription_core_folder\n```\nThis will create folder (inside your env lib directory) with json file storing path to wagtail-transcription package. Later setps are the same.\n\n\nAfter installation add `wagtail_transcription` and `notifications` to your installed apps:\n***Note: Make sure that 'wagtail_transcription' is added before 'wagtail.admin'. Otherwise, administration page will not work properly***\n```\nINSTALLED_APPS = [\n    ...\n    'wagtail_transcription',\n\t'notifications',\n\t...\n]\n```\n\n## SetUp\n##### 1. Run migrations\nAfter installing wagtail-transcription and adding it to installed apps run migrations:\n```\npython manage.py migrate\n```\n\n##### 2. Add wagtail-transcription urls\nAdd following to your project urls.py\n```\nfrom django.urls import include, path, re_path\nfrom wagtail_transcription import urls as wagtail_transcription_url\nimport notifications.urls\n\nurlpatterns = [\n\t...\n    path(\"wagtail_transcription/\", include(wagtail_transcription_url)),\n    re_path(r'^inbox/notifications/', include(notifications.urls, namespace='notifications')),\n\t...\n]\n```\n\n\n##### 3. Add ASSEMBLY_API_TOKEN\nIn your settigns file add '**ASSEMBLY_API_TOKEN**' ([to get it create Assembly Ai account](https://app.assemblyai.com/signup \"to get it create Assembly Ai account\"))\n```\nASSEMBLY_API_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n```\n\n##### 4. Add YouTube Data API token\nIn your settings file add **YOUTUBE_DATA_API_KEY**. To create one check [official documentation](https://developers.google.com/youtube/v3/getting-started \"official documentation\").\n\n```\nYOUTUBE_DATA_API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n```\n\n##### 5. Forward your localhost (developement)\n<b style=\"color:red;\">IMPORTANT</b>\nAfter transcription process ends [AssemblyAi](https://www.assemblyai.com/ \"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](https://theboroer.github.io/localtunnel-www/ \"localltunnel\").\n\n##### 6. Add BASE_URL \nIn your settings file add '**BASE_URL = \"base_url\"**' this is used when sending webhook_url for [AssemblyAi](https://www.assemblyai.com/ \"AssemblyAi\"). In developement you should set it to forward url. If you use [localltunnel](https://theboroer.github.io/localtunnel-www/ \"localltunnel\") it will be something like this **'https://your_subdomain.loca.lt'**\n```\nBASE_URL = \"base_url\"\n```\n\n##### 7. Add DOCUMENTS_GROUP (Optional) \nIn your settings file add '**DOCUMENTS_GROUP = True**'  to create menu group from wagtail documents and transcription\n```\nDOCUMENTS_GROUP = True\n```\n\n\n## Usage\nIn model that you want to add dynamically generated transcryption\n```\nfrom wagtail_transcription.edit_handlers import VideoTranscriptionPanel\nfrom wagtail_transcription.models import Transcription\n\nclass YourModel(Orderable, models.Model):\n    video_id = models.CharField(max_length=255, blank=True)\n    transcription = models.ForeignKey(\n        Transcription,\n        null=True,\n        blank=True,\n        on_delete=models.SET_NULL,\n        related_name='+'\n    )\n\n    panels = [\n        MultiFieldPanel([\n            VideoTranscriptionPanel('video_id', transcription_field='transcription'),\n            FieldPanel('transcription'),\n        ], heading=\"Video and Transcription\"),\n    ]\n```\n**video_id** field accept only youtube video id (not urls).<br/>\n**VideoTranscriptionPanel** takes five arguments:\n- field_name - name of field for video_id\n- transcription_field - name of transcription field\n- custom_class - class of transcription widget\n- custom_css - custom css that will be loaded with transcritpion widget\n- custom_js - custom js that will be loaded with transcritpion widget\n\n<b style=\"color:red;\">IMPORTANT</b>\nYou can only generate a transcript on an existing object, if you try to do this in page creation view you will get an error.\n\n## Customization\nTo be more comfortable with customization checkout [AssemblyAi Docs](https://www.assemblyai.com/docs/ \"AssemblyAi Docs\")\n#### Add custom Transcription Widget class, css and js\nIn your VideoTranscriptionPanel add\n```\nVideoTranscriptionPanel('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'),\n```\n\n#### Add custom RequestTranscriptionView\nIn your settings add\n```\nREQUEST_TRANSCRIPTION_VIEW = \"app_name.module_name.YourRequestTranscriptionView\"\n```\nYou can easily overwrite how request to AssemblyAi is send by overwriteing request_audio_transcription method\n```\nfrom wagtail_transcription.views import RequestTranscriptionView\nclass YourRequestTranscriptionView(RequestTranscriptionView):\n\n    def request_audio_transcription(self, audio_url, webhook_url):\n        \"\"\"\n\t\tYour awesome request logic\n\t\t\"\"\"\n        return response\n```\n\n#### Add custom ReceiveTranscriptionView\nIn your settings add\n```\nRECEIVE_TRANSCRIPTION_VIEW = \"app_name.module_name.YourReceiveTranscriptionView\"\n```\nNow you can easily overwrite how request with transcription is processed\n\n```\nfrom wagtail_transcription.views import ReceiveTranscriptionView\n\nclass YourReceiveTranscriptionView(ReceiveTranscriptionView):\n\n    def process_transcription_response(self, transcription_response, \tvideo_id, model_instance_str, field_name, transcription_field):\n        \"\"\"\n        transcription_response - AssemblyAi response with transcription data \n        video_id - id of youtube video for which transcription was made\n        model_instance_str - string that allow to get model instance \"app:model_name:instance_id\"\n        field_name = name of field with video_id\n        transcription_field = name of field for transcription\n        \"\"\"\n        ...\n\t\tYour transcription processing logic here\n\t\t...\n\t\tsuper().process_transcription_response(transcription_response, \tvideo_id, model_instance_str, field_name, transcription_field)\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.0.16",
    "project_urls": {
        "Bug Tracker": "https://github.com/LilJack118/wagtail-transcription/issues",
        "Homepage": "https://github.com/LilJack118/wagtail-transcription"
    },
    "split_keywords": [
        "wagtail",
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ec3ed53291342f403bc2a6a5a95e7d9d417ec9951d5ad7319a660fcae5674933",
                "md5": "fcdb85839e59a7ccd5a5dae864f1945e",
                "sha256": "196a7a8f23f3e3944d36e7935ca5c296fde5e022562a3f3daed3ffb7fbead66d"
            },
            "downloads": -1,
            "filename": "wagtail_transcription-0.0.16-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fcdb85839e59a7ccd5a5dae864f1945e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 37894,
            "upload_time": "2024-03-08T13:15:42",
            "upload_time_iso_8601": "2024-03-08T13:15:42.041227Z",
            "url": "https://files.pythonhosted.org/packages/ec/3e/d53291342f403bc2a6a5a95e7d9d417ec9951d5ad7319a660fcae5674933/wagtail_transcription-0.0.16-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5b3b3c8a059a69d7b717eca895d4a11498116e7054b487e2f097782c25b29b4b",
                "md5": "55a5bc76be6c9322937b2231669d8ca8",
                "sha256": "6a8db0f7c27f3b3684865279a778af4f3faaa73292f28d201b5133d1dd2efcf1"
            },
            "downloads": -1,
            "filename": "wagtail-transcription-0.0.16.tar.gz",
            "has_sig": false,
            "md5_digest": "55a5bc76be6c9322937b2231669d8ca8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 26221,
            "upload_time": "2024-03-08T13:15:43",
            "upload_time_iso_8601": "2024-03-08T13:15:43.439211Z",
            "url": "https://files.pythonhosted.org/packages/5b/3b/3c8a059a69d7b717eca895d4a11498116e7054b487e2f097782c25b29b4b/wagtail-transcription-0.0.16.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-08 13:15:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "LilJack118",
    "github_project": "wagtail-transcription",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "requirements": [
        {
            "name": "Django",
            "specs": [
                [
                    ">=",
                    "4.1"
                ],
                [
                    "<",
                    "4.2"
                ]
            ]
        },
        {
            "name": "wagtail",
            "specs": [
                [
                    ">=",
                    "4.0"
                ],
                [
                    "<",
                    "4.1"
                ]
            ]
        },
        {
            "name": "django-notifications-hq",
            "specs": [
                [
                    "==",
                    "1.7.0"
                ]
            ]
        },
        {
            "name": "python-docx",
            "specs": [
                [
                    ">=",
                    "0.8.11"
                ]
            ]
        },
        {
            "name": "pytube",
            "specs": [
                [
                    ">=",
                    "12.1.0"
                ]
            ]
        },
        {
            "name": "psycopg2",
            "specs": [
                [
                    "==",
                    "2.9.3"
                ]
            ]
        }
    ],
    "lcname": "wagtail-transcription"
}
        
Elapsed time: 3.13392s