Skip to content
Language-Research-TechnologyPublic

About

Simple browser-based interface for displaying audio recordings and associated transcripts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

137 Commits

Folders and files

Repository files navigation

TrACE

Transcribed Audio Collection Explorer (TrACE) is a simple web-interface for exploring audio recordings and associated transcripts. TrACE is built with HTML and JavaScript without any dependencies, and does not require internet access.

Main features:

  • Synchronized audio and transcripts
  • Transcript search
  • Filters: find recordings with a certain type of speakers

Demo: https://precariousoralhistories.com/TrACE_demo/

Overview

To create a TrACE, you need at least the following files:

  • TrACE_template.html contains the TrACE itself. You can open the file in any browser, as long as it has access to the data, as described below. You can rename the file as needed.
  • Audio files
  • Two data files holding annotations and speakers information, see details below

Data files have simple structure and can be created in any way you want. However, to facilitate TrACE packaging, we provide a make_trace.pyz script. It can be run both in a point-and-click mode, or as a command line program, as described in the next section.

Creating new TrACE

Starting example

make_trace.pyz requires Python 3.9 or later to run. Point-and-click mode requires Tcl/Tk, which is usually included with Python; if you don't have it, see below on how to get it.

To build the example TrACE page, first download the data and the scripts, by running the following in the command line:

git clone https://github.com/Language-Research-Technology/TrACE
cd TrACE

Next, run make_trace.pyz to prepare TrACE. To use a point-and-click interface, run:

python make_trace.pyz

Use the interface to provide the following settings:

  • Audio folder: examples/audio
  • ELAN folder: examples/elan
  • Speakers CSV file: examples/speakers_info.csv
  • Recordings CSV file: examples/recordings_info.csv
  • Help file: examples/help_text.txt
  • Logos file: examples/logos.csv

Then click Run. A new TrACE folder will be created, holding all the necessary files. To open the interface, open the TrACE.html file inside that folder.

Alternatively, all processing can be done from command line:

python make_trace.pyz \
        --audio_dir examples/audio \
        --elan_dir examples/elan \
        --speaker_info examples/speakers_info.csv \
        --recordings_info examples/recordings_info.csv \
        --help_file examples/help_text.txt \
        --logos_file examples/logos.csv \
        --output_dir .

Re-running TrACE

make_trace.pyz tries to remember processing options that you used and will re-use them if you don't provide new values to the script.

If a TrACE output folder exists, the script will read appearance options (described below) from the existing TrACE HTML page.

Furthermore, it saves input file paths and appearance options to TrACE_last_successful_run.json. File paths will be re-used on the next re-run. Appearance options will be re-used if no existing TrACE page is found, e.g., if you have removed it.

Processing options

Run python make_trace.pyz -h for a description of all processing options. In the point-and-click interface, hover over fields and buttons to see their description.

Customising the interface

Some aspects of the interface appearance can be customized by providing options to make_trace.pyz.

  • Title: page title as shown in the browser tab, bookmarks etc.
  • Header: main header of the page
  • Colors:
    • Primary color of the interface (default: #228be6)
    • Highlight of the current annotation (default: #faffa1)
    • Highlight for the filter matches (default: #c2fad2)

Licence and help files

You can provide custom licence and/or help files. You can write them in plain text or in Markdown (see examples/help_text.txt for an example). If you include them, they can be opened with buttons in the top left corner of the screen.

Licence text will be shown once at the beginning of each session; users need to click "Accept" to dismiss the message and start working with TrACE.

Header logos

Logos of your project, partners or funders can be shown under the page header. When preparing TrACE with make_trace.pyz, you can list them in a CSV file (--logos_file in the command line, or "Logos CSV file" in the graphical interface).

The CSV file needs to contain the folowing columns (see examples/logos.csv for an example):

  • image -- path to the image file, relative to the CSV file. Supported formats: PNG, JPEG, GIF, SVG, WebP.
  • text -- text to show instead of an image, for logos without an image
  • url -- page to open when the logo is clicked (optional)
  • title -- text shown when hovering the mouse over the logo (optional)

Each logo needs either an image or a text value. Logos are embedded into the HTML file, so they don't need to be copied together with it.

Annotation labels

Annotations can have labels, e.g. the themes discussed or the languages used (see the label field in transcripts.js). Labels are shown to the left of the transcript: consecutive annotations with the same label form a section, marked by a colored bracket with the label at its start and end. Above the transcript, there is a chip for each label of the recording:

  • Click a label's chip to focus on it: only the labels focused on are shown, in the transcript and in the audio player. Click more chips to focus on more labels, and click a chip again to stop focusing on it.
  • Hover over a chip and click the small "×" to hide that label, e.g. to declutter the overview. Click a hidden label's chip to show it again.
  • "All" shows all labels again. If all labels are shown already, it hides them all.
  • The arrows next to the chips step through the sections of the labels shown; the arrows on the brackets jump to the previous / next section with the same label.

While labels are focused on, the recordings which contain them are marked with colored dots in the list of recordings.

Adding labels

make_trace.pyz can add labels to the annotations from a CSV file (--labels_file in the command line, or "Labels CSV file" in the graphical interface). Each row gives the labels of one annotation, which is found by its ELAN file, tier and start time. One way to make the file:

  1. In ELAN, export the annotations as tab-delimited text (File > Export As > Tab-delimited Text, or File > Export Multiple Files As > Tab-delimited Text for several files). Include the tier names, and the begin time in milliseconds (time formats like 00:01:23.450 are not accepted, and Excel tends to change them). For several files, also include the file names.

  2. Open the export in Excel, and add a header row with column names. These columns are needed, named exactly so:

    • elan_file -- name of the ELAN file, exactly as in the elan_file column of the recordings CSV
    • tier -- name of the tier
    • start -- start time of the annotation in milliseconds
    • label -- label(s) of the annotation; several labels are separated by ";", e.g. Work; Housing (spaces around the labels are ignored)

    Other columns (e.g. the text of the annotations) are ignored, so they can stay.

  3. Add a label column and fill it in. Annotations with an empty label get no labels.

  4. Save the file as "CSV UTF-8 (Comma delimited)".

For example:

elan_file,tier,start,label
Bwd1.eaf,Martha,4500,Work; Housing
Bwd1.eaf,Martha,7220,Housing

Rows that can't be used are skipped and reported, so that mistakes don't go unnoticed: rows that match no annotation, ELAN files that are not in the recordings CSV, start times that are not in milliseconds, and several rows for the same annotation (none of them is used; to give an annotation several labels, separate them with ";" in one row).

Label settings

The labels' settings can be changed in the TEMPLATE VARIABLES section at the top of the TrACE page (make_trace.pyz doesn't overwrite a page edited by hand, unless asked to):

  • annThemeField -- name of the annotation field with the labels (default: label)
  • themeControlsHeading -- heading of the chips (default: Labels:), e.g. Themes: or Languages:
  • themeSectionMaxGap -- how many annotations without labels (e.g. questions of the interviewer) can be between two annotations with the same label, so that they still form one section (default: 2)
  • fixedThemeColors -- colors for specific labels, e.g. {"Work": "#4e79a7"}; other labels get colors automatically

Technical details

Data structure

The interface assumes the existence of three data sources:

  • Folder with audio files
  • speakers.js -- information about speakers
  • transcripts.js -- time-stamped transcripts

It is assumed that all of them are in the same folder with the TrACE HTML page.

speakers.js

The file should contain a Java Script constant named speakers. The constant should hold a JSON list, where each element is a JSON dictionary holding info about a single speaker. Each speaker should have at least one field "Name". Any other fields can have arbitrary names. A field can hold several values, separated by ";", e.g. "Languages": "English; French"; spaces around the values are ignored.

Show example
const speakers = [
  {
    "Name": "Dawn",
    "Gender": "Female",
    "Age Group": "36-50"
  },
  {
    "Name": "Dustin",
    "Gender": "Male",
    "Age Group": "66+"
  }

transcripts.js

The file should contain a Java Script constant named transcripts. The constant should hold a JSON list, where each element is a JSON dictionary holding annotations for a single transcript. The dictionary should have the following fields:

  • filename -- path to the audio file
  • displayName -- display name for the audio in the list of recordings
  • speakers -- a list of speakers present in the recording. Names of the speakers should match the names in the speakers.js file.
  • annotations -- a list of dictionaries, where each entry corresponds to a single annotation and contains the following fields:
    • ANNOTATION_ID
    • TIER_ID (contains a speaker's name)
    • content -- annotation text
    • start -- start timestamp in milliseconds
    • end -- end timestamp in milliseconds
    • label (optional) -- label(s) of the annotation, e.g. its theme; several labels can be separated by ";", and spaces around them are ignored (see Annotation labels)
Show example
const transcripts = [
  {
    "filename": "audio/Bwd1.mp3",
    "displayName": "Martha",
    "speakers": [
      "Martha"
    ],
    "annotations": [
      {
        "ANNOTATION_ID": "a1",
        "TIER_ID": "Martha",
        "content": "and when he got over there to find that they weren't there, it was like, oh my God.",
        "start": 0,
        "end": 4500
      },
      {
        "ANNOTATION_ID": "a2",
        "TIER_ID": "Martha",
        "content": "Where are they? What? We couldn't see where they'd been",
        "start": 4500,
        "end": 7220
      }
    ] 
  }
]

Building make_trace.pyz

make_trace.pyz is an executable zip archive (see https://docs.python.org/3/library/zipapp.html). The code for it is stored in the make_trace folder.

To build make_trace.pyz, run python build/package.py in the repo directory. The HTML template is embedded directly into make_trace.pyz at this step, so that the script can be used completely on its own to generate TrACE.

Credits

TrACE was created by Wolfgang Barth and Anton Malko, as part of LDaCA team at the Australian National University.

About

Simple browser-based interface for displaying audio recordings and associated transcripts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages