External APIs
Automatic Subtitle Generation (with Sonix.ai)
Introduction
The Automatic Subtitle Generation feature is designed to provide high-quality subtitles in multiple languages for the teaching videos on the platform. This feature uses Sonix.ai, an online transcription service, to transcribe the videos and generate subtitles in German, which can then be translated into other languages such as English, Russian, Polish, and Turkish. This document provides an overview of the process, designed to be understandable for non-technical users.
Automatic Subtitle Generation Process
- Video Upload and Topic Specification: The admin uploads a teaching video to Vimeo and specifies the topic(s) the video covers. This information is essential for generating accurate subtitles and translations in the following steps.
- Subtitle Generation Action: After adding the video to the platform, the admin can choose the action to generate the subtitles. This initiates the process of downloading the video from Vimeo and sending it to Sonix for transcription.
- Transcription and Subtitle Creation: With the help of custom dictionaries, explained in the next chapter, Sonix transcribes the video's audio into text and generates high-quality subtitles in German. These German subtitles can then be translated into other available languages.
- Subtitle Download and Upload: After subtitles in all languages have been created, they are downloaded from Sonix and uploaded to Vimeo. Users can now activate subtitles when watching the videos and choose their preferred language. All available subtitles are displayed in the admin panel.
Custom Dictionaries
Custom Dictionaries play a crucial role in enhancing the accuracy of the transcription process. They are used to provide Sonix with lists of topic and domain-specific vocabulary that may not be recognized by the service due to their uncommon nature in general language. By incorporating these specialized terms, Custom Dictionaries allow Sonix to generate high-quality subtitles that accurately reflect the content of the teaching videos.
To create Custom Dictionaries, Python scripts have been developed that analyze multiple documents containing domain-specific texts, such as books and slides from video tutorials. These scripts identify the unique terms relevant to the subject matter and compile them into a list. The resulting Custom Dictionary is tailored to the specific topic covered in the video, ensuring that even the most specialized vocabulary is transcribed correctly.
Handling Transcription Errors
In case transcription errors are identified in the generated subtitles, admins can edit the subtitles in Sonix to correct any mistakes. The edited subtitles can then be re-uploaded to Vimeo to ensure accurate and high-quality content for the users.
Conclusion
The Automatic Subtitle Generation feature offers a comprehensive and efficient solution for creating multilingual subtitles for teaching videos on the platform. By leveraging Sonix.ai, custom dictionaries, and automatic translations, this feature ensures that even domain-specific vocabulary is transcribed accurately, resulting in high-quality subtitles for users in their preferred language. This enhanced
Custom Dictionary Generation
Summary
To generate a custom dictionary for a specific topic, you can follow the following simple steps:
Place PDF and PPTX files with relevant vocabulary for the corresponding topic in a specific folder.
Specify the path to this folder in the Jupyter notebook.
Execute the Jupyter notebook.
This will automatically generate a custom dictionary for Sonix.ai and save it in the assets/sonix folder. The dictionary can thereafter be reviewed and uploaded to Sonix.ai.
Details on the Generation of a Custom Dictionary
This chapter explains the generation of custom dictionaries in more (technical) detail. The generation of a custom dictionary is performed in the Jupyter notebook gen_topic_custom_dict_from_folder.ipynb located in the repository's root folder. It consists of the following steps:
Read in PDF and PPTX files with relevant vocabulary for the corresponding topic from the specified folder.
Extract the whole textual content from the files using file type specific methods. The corresponding scripts are stored in
utils/pdf.pyandutils/pptx.py.Clean the extracted text and tokenize it into a document using the scripts provided in
utils/nlp.py.Generate trigrams to capture phrases like 'Arbeits- und Sozialvorschriften' which are often occurring in the analyzed corpus and extend the document by the trigram tokens.
Extract acronyms from the document.
Extract the abbreviation candidates from the texts and remove them from the document.
Clean the resulting tokens from stopwords using a list of almost 2k stopwords (
assets/german_corpora/stop_words/stop_words_full.txt). This step includes repairing many broken words caused by line- or page-breaks, info-boxes, etc. in the reference documents.Generate a pandas dataframe with token statistics including their document frequency (count), length, and a document-size-normalized frequency (see calculation in
nlp.py:tokens_to_vocabs_df(tokens:list)). This ensures comparability of term frequencies across documents of very different sizes including the log transformation.Extract candidate tokens for the custom dictionary (CD) by comparing it with a 7.4 Million words strong German vocabulary generated from all German Wikipedia articles as of November 2021 (
assets/german_corpora/de_wiki_nov21_cleaned.csv).Words in the given text not present in the German corpus.
Words that are much more frequent in the provided texts compared to the German corpus, where for frequency we use the self-defined log-normalized document frequency of tokens.
Filter candidate tokens based on empirical hand-crafted rules (e.g., based on token length and frequency or based on the difference between document frequency in the German corpus and the provided files, etc.).
Save the generated custom dictionaries in multiple formats (human-friendly as CSV and sonix-required as TXT) including separate lists of extracted acronyms and 2nd priority tokens indicating potentially relevant tokens that have been excluded during automatic filtering (potential false negatives).
Review the Dictionary
The generated dictionaries are of high quality and reliability. As with all automatically generated content, however, to get the most out of it, it is recommended to review it by an expert. Cleaning up the last 5% of errors would require a too high manual effort which would be a non-effective decision.
Code Overview
If you want to make adjustments to the algorithmic details of the custom dictionary generation, it is useful to understand the structure of the whole code repository. Below is a high-level overview of the repository structure with a more detailed description of relevant parts of the repository.
The most important notebook is
gen_topic_custom_dict_from_folder.ipynblocated in the root path of the repository. It is the only script that needs to be executed to generate new custom dictionaries.The most important folders are
assets/german_corpora,assets/sonix/topic_custom_dictionaries, andutils/*.assets/german_corporacontains the corpora used to generate a representative vocabulary of the German language, withassets/german_corpora/de_wiki_nov21_cleaned.csvbeing the one finally used for the generation of custom dictionaries.assets/sonix/topic_custom_dictionariescontains the final custom dictionaries in multiple formats (human-friendly and sonix-required) including separate lists of extracted acronyms and 2nd priority tokens indicating potentially relevant tokens that have been excluded during automatic filtering (potential false negatives).The
utilsfolder contains the main scripts necessary to perform each step of the generation of custom dictionaries. Its main scripts are explained below.
The main scripts in the
utilsfolder are:pdf.pyandpptx.py: Containing the necessary logic to extract text from PDFs and PPTX, providing the vocabulary for the topic of interest.nlp.py: Providing scripts for natural language processing, including tokenization, trigram-generation, acronym and abbreviation extractions, generation of term frequency data frames, etc.
Other folders are of less importance and should be only considered for getting a deep understanding of the underlying steps and taken decisions in the development process. As the folder names suggest, they contain experimental Jupyter notebooks created during the exploration of the data, different libraries, solution designs, etc.