Reaper reference

From Phonlab
Jump to navigationJump to search

reaper command line tool

The reaper command line tool extracts F0 measurements from an audio file. It was written by David Talkin and is a successor to the get_f0 command from the ESPS tools. Users of the Berkeley Phonetics Machine can install it with sudo bpm-update reaper command.

The reaper tool is not very heavily documented. To see the available options, run the command with no arguments:

 reaper

The available options will be listed. You can also consult the source repository for more information or to inspect the code.

A simple example that writes timestamped F0 measurements to an easy-to-read text file is:

 reaper -i myfile.wav -a -f myfile.f0

The -i parameter identifies the input file, and the -f parameter names the output file to be created. The -a option declares that the output file will be plaintext rather than an encoded binary format.

The output file contains a header of several lines before the data section starts. You can copy and adapt the following code to skip the header and read the data section into a Pandas dataframe:

 
# This assumes you have already done
# import pandas as pd
# import numpy as np

with open('temp.f0', 'r') as f:
    '''Skip past header, then use read_csv() on open file buffer.'''
    line = f.readline()
    while not line.startswith('EST_Header_End'):
        line = f.readline()
    df = pd.read_csv(
        f,
        sep=' ',
        names=['sec', 'is_voiced', 'f0'],                        # Give useful names to the columns
        na_values={'f0': '-1.000000'},                          # Replace dummy reaper values with NaN
        dtype={'sec': np.float32, 'is_voiced': bool, 'f0': np.float32}
    )

Notice that column names are specified in the names parameter, and reaper's F0 non-measurement placeholder -1.000000 is replaced with NaN.