Difference between revisions of "Reaper reference"

From Phonlab
Jump to navigationJump to search
 
(7 intermediate revisions by the same user not shown)
Line 13: Line 13:
 
reaper -i myfile.wav -a -f myfile.f0
 
reaper -i myfile.wav -a -f myfile.f0
   
The <code>-i</code> parameter identifies the input file, and the <code>-f</code> parameter names the output file to be created. The <code>-a</code> option declares that the output file will be plaintext rather than an encoded binary format.
+
The <code>-i</code> parameter identifies the input file, and the <code>-f</code> parameter names the output file to be created. The <code>-a</code> option declares that the output file will be plaintext rather than <code>reaper</code>'s default 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:
 
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:
   
<nowiki>
+
<nowiki>
 
 
# This assumes you have already done
 
# This assumes you have already done
 
# import pandas as pd
 
# import pandas as pd
 
# import numpy as np
 
# import numpy as np
   
with open('temp.f0', 'r') as f:
+
myfile = 'temp.f0'
  +
with open(myfile, 'r') as f:
 
'''Skip past header, then use read_csv() on open file buffer.'''
 
'''Skip past header, then use read_csv() on open file buffer.'''
 
line = f.readline()
 
line = f.readline()
Line 31: Line 31:
 
f,
 
f,
 
sep=' ',
 
sep=' ',
names=['sec', 'is_voiced', 'f0'], # Give useful names to the columns
+
names=['sec', 'is_voiced', 'f0'], # Give useful names to the columns
na_values={'f0': '-1.000000'}, # Replace dummy reaper values with NaN
+
na_values={'f0': '-1.000000'}, # Replace dummy reaper values with NaN
 
dtype={'sec': np.float32, 'is_voiced': bool, 'f0': np.float32}
 
dtype={'sec': np.float32, 'is_voiced': bool, 'f0': np.float32}
)
+
)</nowiki>
</nowiki>
 
   
 
Notice that column names are specified in the <code>names</code> parameter, and <code>reaper</code>'s F0 non-measurement placeholder <code>-1.000000</code> is replaced with NaN.
 
Notice that column names are specified in the <code>names</code> parameter, and <code>reaper</code>'s F0 non-measurement placeholder <code>-1.000000</code> is replaced with NaN.

Latest revision as of 16:13, 20 February 2018

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 reaper's default 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

myfile = 'temp.f0'
with open(myfile, '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.