Skip to main content

A sentence-level text-audio alignment tool for conference calls.

Project description

ccalign

ccalign is designed to simplify sentence-level text-audio alignment for analyzing conference calls. Further details can be found in the original research paper.

Please note that this repository is at an early stage. Further updates and improvements will follow shortly.

Setup and Installation

This repository has currently only been tested on Linux (Ubuntu 22.04 jammy).

  • GPU transcription execution requires the NVIDIA libraries cuBLAS 11.x and cuDNN 8.x to be installed on the system.

  • You also need to install FFmpeg on your system. You can follow openAI instructions.

  • Make sure to create and activate a virtual environment for a non-global installation:

    python3 -m venv venv_ccalign

    source venv_ccalign/bin/activate

1. Install torch and CUDA11.8

You can install PyTorch and CUDA using pip:

pip install torch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 --index-url https://download.pytorch.org/whl/cu118

You can check the PyTorch homepage for more setups.

2. Install whisperx

The repository depends on whisperx. You can install the latest version using pip:

pip install git+https://github.com/m-bain/whisperx.git

3. Install ccalign

You can install ccalign using pip:

pip install ccalign

Preprocessing, Input and Output

Needed Input

The alignment requires specific preprocessing of the transcript. A pandas DataFrame or a Dataset with the following variables must be provided:

  • A unique ID. Feature name: 'id'
  • A path to the conference call audio file. Feature name: 'path_audio'
  • A path to the preprocessed conference call transcript. Feature name: 'path_transcript'

Preprocessed conference call transcript

The conference call transcript must be preprocessed at paragraph level (speaker changes) and contain the original text, the speaker and information about the call section. The call section can be any of the following strings:

  • "-OP-": Operator instructions
  • "-PR-": Presentation of a company executive
  • "-Q-": An analyst question
  • "-Q_A-": Question answer of a company executive

The preprocessed information must be provided in the following JSON format:

Example: Earnings Conference Call JSON Format

{
  "paragraphs": [
    {
      "text":
        "Welcome to the ABC Corporation fourth quarter earnings conference call. My name is Jane, and I will be the operator for today's call.
        Thank you for joining us.",
      "speaker": "Operator",
      "call_section": "-OP-"
    },
    {
      "text":
        "Thank you, Jane. Good morning, everyone, and thank you for joining our earnings call.
        Today, we will discuss our results for the fourth quarter and provide an outlook for the upcoming year.",
      "speaker": "John Doe",
      "call_section": "-PR-"
    },
    {
      ...
    }
  ]
}

Output

As a first step, the execute_whisperx() function transcribes the audio file with word-level timestamps using whisperx. The transcription files (whisper and whisperx) are saved as a JSON file in the same folder as the audio file. If you already have the whisperx timestamps, you can simply define the path in the DataFrame or Dataset as "path_whisperx" and skip this step.

Second, the execute_alignment() function aligns the Whisperx output with the original transcript.
Sentence-level timestamps, alignment statistics and word-level timestamps are exported to a directory called ccalign_results in the current working directory. Word-level timestamps are experimental at this time.

Configurations

The following is an explanation of the configuration parameters used in the project:

  • model: Specifies the transcription model based on Whisper, which converts audio input into text.
  • device: Defines the hardware (e.g., CPU or GPU) used for transcription.
  • batch_size: Determines the number of audio data batches processed simultaneously within a single run of the Whisper model. This impacts processing speed and memory usage.
  • compute_type: Specifies the data type (e.g., fp16 or int8) used for computations in the Whisper model, affecting performance and accuracy.
  • num_processes_whisperx: Sets the number of parallel transcription processes used for processing. The number should be adjusted based on available GPU memory.
  • num_processes_alignment: Defines the number of parallel alignment processes used. These processes run exclusively on the CPU.
  • calls_per_core: Specifies how many conference calls are processed by a single process. A backup of the alignment process is created after processing a number of calls equal to num_processes_alignment * calls_per_core.

Python usage

Command line execution is not available at this time. For licensing reasons, we are unable to provide conference calls to test the code.

from ccalign import execute_whisperx, execute_alignment 
import pandas as pd
import torch
import multiprocessing as mp

df = pd.read_pickle(r'path/to/dataframe.pkl')

device, dtype = ("cuda", "float16") if torch.cuda.is_available() else ("cpu", "float32")
cpu_cores = mp.cpu_count()

df = execute_whisperx(
    path_data=df,
    model="base.en",
    batch_size_whisper=16,
    num_processes_whisperx=2,
    device=device,
    dtype=dtype
    )
        

df = execute_alignment(
    path_data=df,
    num_processes=cpu_cores - 2,
    calls_per_core=10
    )

License

  • This repository depends on whisperx (BSD 2-Clause License).
  • This repository is licensed under the MIT license.

Contact/Support

We look forward to any suggestions for improvement or support. Feel free to get in touch!

Citation

@article{ewertz2024,
  title={Listen Closely: Listen Closely: Measuring Vocal Tone in Corporate Disclosures},
  author={Ewertz, Jonas and Knickrehm, Charlotte and Nienhaus, Martin and Reichmann, Doron},
  year={2024},
  note={Available at SSRN: \url{https://ssrn.com/abstract=4307178}
  }

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ccalign-0.0.1.tar.gz (43.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ccalign-0.0.1-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file ccalign-0.0.1.tar.gz.

File metadata

  • Download URL: ccalign-0.0.1.tar.gz
  • Upload date:
  • Size: 43.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for ccalign-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ff6e07c188b24172ae4a1b4d5133927a488bab45b7f4ebe2be16a3f248fbd324
MD5 dbc89ee352fb70e00c287ed02aea0251
BLAKE2b-256 db5e95ad8fe137f489a225c62410fcdc1727719acf213cc3bfb07ef987757aa1

See more details on using hashes here.

File details

Details for the file ccalign-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ccalign-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for ccalign-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a179ad42e4b2c64e416423217aed44c6e544c53b3d62636a0ad408cb99b19cdb
MD5 9b84e11d3b9848edef42ef9e048aa1ec
BLAKE2b-256 b3c5d02d8293c7b35c4eb475db4e254ccdd3d0ac1e55b2df7d5b05c45b60e00b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page