Skip to main content

CoPaSul - Contour-based, parametric, and superpositional intonation stylization

Author

  • Uwe Reichel, Research Institute for Linguistics, Hungarian Academy of Sciences, Budapest

Purpose: Prosodic Feature extraction

  • Intonation
    • Global f0 register
    • Local f0 shapes
    • Prosodic boundaries
  • Energy
  • Rhythm
  • Voice quality

Dependencies

  • Python: >= 3.8
  • Packages: see requirements.txt
  • tested for Linux and Python 3.8, and 3.10

Installation

From PyPI

  • set up a virtual environment venv_copasul, activate it, and install copasul. For Linux this works e.g. as follows:
$ virtualenv --python="/usr/bin/python3" venv_copasul
$ source venv_copasul/bin/activate
(venv_copasul) $ pip install copasul

From GitHub

$ git clone git@github.com:reichelu/copasul.git
$ cd copasul/
$ virtualenv --python="/usr/bin/python3" venv_copasul
$ source venv_copasul/bin/activate
(venv_copasul) $ pip install -r requirements.txt

Usage

Required files

  • audio (wav), f0, pulse, and annotation files (Textgrid), see on GitHub: tests/minex/input
  • a config file (json), see on GitHub tests/minex/config/minex.json
    • see on Github docs/copasul_commented_config.json.txt and the article for further details

Extract f0 and pulse by means of Praat

# add this line if you use the code from GitHub
# sys.path.append(PROJECT_ROOT)

from copasul import praat_utils

# Praat pitch extractor
piex = praat_utils.PraatPitchExtractor(
    hopsize=0.01, minfreq=75, maxfreq=600)

# process mono files
piex.process_mono_files(
    input_dir=INPUT_AUDIO_DIR,
    output_dir=OUTPUT_PITCH_DIR,
    input_ext="wav",
    output_ext="f0"
)

# ... in order to process stereo files, use:
# piex.process_stereo_files()

# Praat pulse extractor
puex = praat_utils.PraatPulseExtractor(
    hopsize=0.01, minfreq=75, maxfreq=400)

# process mono files
puex.process_mono_files(
    input_dir=INPUT_AUDIO_DIR,
    output_dir=OUTPUT_PULSE_DIR,
    input_ext="wav",
    output_ext="pulse"
)

# ... in order to process stereo files, use:
# puex.process_stereo_files()

Call Copasul from terminal (if cloned from GitHub)

  • see on example script
  • python scripts/run_copasul.py [-c myConfigFile.json]
  • PROJECT_ROOT: directory where GitHub project has been cloned
(venv_copasul) $ cd PROJECT_ROOT/scripts/
(venv_copasul) $ python run_copasul.py -c ../tests/minex/config/minex.json
  • if you use ../tests/minex/config/minex.json as config file, CoPaSul
    • processes the files in ../tests/minex/input/, and
    • outputs feature tables to ../tests/minex/output/test.FEATURESET.{csv, R}
    • outputs the CoPaSul output dict to ../tests/minex/output/test.pickle
    • this output dict can be used for further (warm start) processing
  • if you use your own config file, make sure, that all directories in fsys:*:dir are either absolute paths or relative paths relative to your config file

Example integration into python code

import json
import pickle
import sys

# add this line if you use the code from GitHub
# sys.path.append(PROJECT_ROOT)

from copasul import copasul

# feature extractor
fex = copasul.Copasul()

# processing based on config file
config_file = MYCONFIGFILE.json
copa = fex.process(config=config_file)

# processing based on config dict
with open(config_file, 'r') as h:
    config_dict = json.load(h)
copa = fex.process(config=config_dict)

# warm start: continue processing
#   - implicit loading from config
config_dict["navigate"]["from_scratch"] = False
config_dict["navigate"]["overwrite_config"] = True
#     ... change further navigation values to your needs
copa_further_processed = fex.process(config=config_dict)

#   - explicit loading from file
copa_file = MYCOPASULOUTPUT.pickle
config_dict["navigate"]["overwrite_config"] = True
#     ... change further navigation values to your needs
with open(copa_file, "rb") as h:
   copa = pickle.load(h)
copa_further_processed = fex.process(config=config_dict, copa=copa)

Material

Reference

Reichel, U.D. (2017). CoPaSul Manual: Contour-based, parametric, and superpositional intonation stylization, arXiv:1612.04765.

Metadata

Release files for copasul 1.5.3

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

Source distribution (sdist)

Source distribution for copasul 1.5.3
File Size Uploaded
copasul-1.5.3.tar.gz 134.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for copasul 1.5.3
File Interpreter ABI Platform
copasul-1.5.3-py3-none-any.whl Python 3 none any Details

Total release size: 264.9 kB

Release files / copasul-1.5.3.tar.gz

Download URL copasul-1.5.3.tar.gz
Size 134.0 kB
Tags Source
SHA-256 checksum
How to use checksums
08e045beb632308115c16eaf891b525ab9e95f1446c5996c017c7c7cd2508a97
BLAKE2b-256 checksum
How to use checksums
62b2f4b518c99d609c76f2fa927ee530c6510ab5cdd13a8721b9320f149501ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.10

Release files / copasul-1.5.3-py3-none-any.whl

Download URL copasul-1.5.3-py3-none-any.whl
Size 131.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd611751de061b2cf955dc154007836ace694929c1181a4729f504374fdb2d36
BLAKE2b-256 checksum
How to use checksums
14a576c6ebb90f31bcbc45584647b53f9b326343ee50a379d0ce11855c5aa66f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.5.3 This release

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

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