Parselmouth is a Python library for the Praat software. Here I use it for generating 4 types of modifications:
- Volume (dB +-)
- Pitch (sets entire audio pitch to x Hz)
- Noise (overlays noise based on SNR)
- Pitch Contour (changes tone)
pip install praat-parselmouth
import json
import os
import sys
import shutil
import numpy as np
import wave
import parselmouth
import glob
from parselmouth.praat import call
from pydub import AudioSegment
openFile(jsonPath, filePath)
Loads in json files (with start and end times of speech) and the path to the audio files. Returns a 2d array in the format [jsonFiles, samples], where jsonFiles is an array of json objects, and samples is an array of pydub AudioSegments.
openModifiers(path)
Loads in noise that will be overlayed on the samples. Returns an array of AudioSegments.
adjustVolume(sample, decibels)
Adjusts sample volume by decibels. Positive or negative.
adjustPitch(wavPath, pitch)
Creates a pitchTier with a pitchPoint at the given pitch, and resynthesis the wav (from wavPath) based on the pitchTier. Saves the new sound in the format
("pitch{}.wav".format(" " + str(pitch) + "Hz"), 'WAV')