> For the complete documentation index, see [llms.txt](https://gitbook.bergelsonlab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.bergelsonlab.com/data-pipeline/personal-information-guidelines/audio-scrubbing.md).

# Audio Scrubbing

## Step 1: addscrubtier

This script automates the process of adding \*SCR tiers into clan files. You can find the [addscrubtier script on GitHub](https://github.com/SeedlingsBabylab/addscrubtier). **Be sure you have the most updated version of addscrubtier before proceeding.**

It looks for "begin personal information" and "end personal information" comments and bases the time interval on those. It will add the \*SCR tier right after the "begin personal information" comment with its timestamp as the interval between personal info comments.

For example:

```
*MAN:   &=w0 . 7109230_7111100
%xcom:  begin personal information: last name
*SCR:   Scrub 7111100_7149210
%xdb:   average_dB="-24.41" peak_dB="-16.85"
*OLN:   0 . 7111100_7147680
%xdb:   average_dB="-22.16" peak_dB="-9.47"
@Eg:    Pause 268
@Bg:    Conversation 268
*MAN:   &=w10_86 . 7147680_7149210
%xcom:  end personal information
```

#### [addscrub.py](http://addscrub.py/)

Run the script using the final, checked .cha file. The output should be named the same as the original but with \_scrubbed added.

```
1 $: python addscrub.py [original_filename] [output_filename]
```

For example:

```
1 $: python addscrub.py 01_06_coderSD_final.cha 01_06_coderSD_final_scrubbed.cha
```

The scrubbed.cha should be saved to the same directory as the unscrubbed final.cha (ex. Subject\_Files/01\_01-01-2016/01\_06/Home\_Visit/Coding/Audio\_Annotation).

#### [batchscrub.py](http://batchscrub.py/)

To run this script on multiple files, use the batchscrub script.

**\[subject] and \[visit] can be "all", or a number.**

```
1 $: python batchscrub.py [start_directory] [subject] [visit]
```

## Step 2: CLAN silence command

1. Once you have a .cha file with SCR tiers, you can move on to adding silence to the audio file. Copy the scrubbed.cha into the directory with the corresponding .wav file (seedlings/Subject\_Files/01\_01-01-2016/01\_06/Home\_Visit/Processing/Audio\_Files).
2. Open the scrubbed.cha in CLAN and open the command window. Change the working directory as needed, and then run the following command:

   ```
   1 silence +sScrub [filename]
   ```

* This CLAN command looks for lines with some specified string and converts the linked segment of the related audio file to silence.
* **Note:** this takes a while to run, so don't panic!

1. This creates a .aif file with silence during the SCR tiers called "XX\_XX-silent.aif". This file should be renamed "XX\_XX\_scrubbed.aif" and should be saved to the same directory as the unscrubbed .wav file (ex. Subject\_Files/01\_01-01-2016/01\_06/Home\_Visit/Processing/Audio\_Files).
2. You can delete the extra copy you made of the scrubbed.cha in the Processing/Audio\_Files folder (leaving the scrubbed.cha in the Coding/Audio\_Annotation folder).

## Step 3: .wav conversion

In the above step, CLAN outputs an .aif file. We prefer to use the more standard .wav format, so now you should convert the file.

1. First, make a local copy of the scrubbed.aif file. To do this, create a folder on your desktop called Sub\_Files and copy and paste the scrubbed.aif into this folder.
2. Open Audacity and open the local scrubbed.aif file.
3. Click File > Export As. Save the file as XX\_XX\_scrubbed.wav in your local folder. Make sure WAV is selected in the Format drop-down menu.
   * A metadata window will pop up. Leave this blank and click OK.
4. Once the conversion process is complete (this shouldn't take more than a few minutes), **move the scrubbed.wav file onto BLab share in the relevant Processing/Audio\_Files folder and delete the extra copies on your desktop.**
