Package: psola
Time-domain pitch-synchronous overlap-add (TD-PSOLA)This module permits contant- and variable-rate pitch-shifting and
time-stretching of speech. It is a wrapper around theparselmouth[1]
wrapper around the Praat [2] implementation of TD-PSOLA [3]. Pitch-shifting
is performed by providing a numpy array of target pitch values equally spaced
over time. Variable-rate time stretching uses forced phoneme alignment viapypar.If you need to extract pitch features or phoneme alignments, seetorchcrepefor pitch estimation
andpyfoalfor forced alignment.
If you only want to perform pitch-shifting, you do not need to extract
forced alignments. If you want to do variable-rate time stretching, you do not
need to perform pitch estimation.Installationpip install psolaUsageIf you want to perform pitch-shifting or time-stretching on audio already
loaded into memory, usepsola.vocode. If you want to do this with audio
saved in a file, usepsola.from_file. You can usepsola.to_fileorpsola.from_file_to_fileto save the results to a file. To process many
files at once with multiprocessing, usepsola.from_files_to_files.
Each of these functions is documented below. The command-line interface
wraps the arguments ofpsola.from_files_to_filesand is described in
the next section.psola.vocode"""Performs pitch vocoding using PraatArgumentsaudio : np.array(shape=(samples,))The speech signal to processsample_rate : intThe audio sampling rate.source_alignment : pypar.AlignmentThe current alignment if performing time-stretchingtarget_alignment : pypar.AlignmentThe target alignment if performing time-stretchingtarget_pitch : np.array(shape=(frames,))The target pitch contourconstant_stretch : float or NoneA constant value for time-stretchingfmin : intThe minimum allowable frequency in Hz.fmax : intThe maximum allowable frequency in Hz.Returnsaudio : np.array(shape=(samples,))The vocoded audio"""psola.from_file"""Performs vocoding using PraatArgumentsaudio_file : stringThe file containing the speech signal to processsource_alignment_file : string or NoneThe file containing the original alignmenttarget_alignment_file : string or NoneThe file containing the target alignmenttarget_pitch_file : string or NoneThe file containing the target pitchconstant_stretch : float or NoneA constant value for time-stretchingfmin : intThe minimum allowable frequency in Hz.fmax : intThe maximum allowable frequency in Hz.Returnsaudio : np.array(shape=(samples,))The vocoded audiosample_rate : intThe audio sampling rate"""psola.to_file"""Performs pitch vocoding and saves audio to diskArgumentsaudio : np.array(shape=(samples,))The speech signal to processsample_rate : intThe audio sampling rateoutput_file : stringThe file to save the vocoded speechsource_alignment : pypar.AlignmentThe current alignment if performing time-stretchingtarget_alignment : pypar.AlignmentThe target alignment if performing time-stretchingtarget_pitch : np.array(shape=(frames,))The target pitch contourconstant_stretch : float or NoneA constant value for time-stretchingfmin : intThe minimum allowable frequency in Hz.fmax : intThe maximum allowable frequency in Hz."""psola.from_file_to_file"""Performs vocoding using Praat and save to diskArgumentsaudio_file : stringThe file containing the speech signal to processoutput_file : stringThe file to save the vocoded speechsource_alignment_file : string or NoneThe file containing the original alignmenttarget_alignment_file : string or NoneThe file containing the target alignmenttarget_pitch_file : string or NoneThe file containing the target pitchconstant_stretch : float or NoneA constant value for time-stretchingfmin : intThe minimum allowable frequency in Hz.fmax : intThe maximum allowable frequency in Hz."""psola.from_files_to_files"""Performs vocoding using Praat and save to diskArgumentsaudio_files : listThe files containing the speech signals to processoutput_files : listThe files to save the vocoded speechsource_alignment_files : string or NoneThe files containing the original alignmentstarget_alignment_files : list or NoneThe files containing the target alignmentstarget_pitch_files : list or NoneThe files containing the target pitchconstant_stretch : float or NoneA constant value for time-stretchingfmin : intThe minimum allowable frequency in Hz.fmax : intThe maximum allowable frequency in Hz."""Command-line interfaceusage: python -m psola
    [-h]
    [--audio_files AUDIO_FILES [AUDIO_FILES ...]]
    [--source_alignment_files SOURCE_ALIGNMENT_FILES [SOURCE_ALIGNMENT_FILES ...]]
    [--target_alignment_files TARGET_ALIGNMENT_FILES [TARGET_ALIGNMENT_FILES ...]]
    [--constant_stretch CONSTANT_STRETCH]
    [--target_pitch_files TARGET_PITCH_FILES [TARGET_PITCH_FILES ...]]
    [--fmin FMIN]
    [--fmax FMAX]
    [--output_files OUTPUT_FILES [OUTPUT_FILES ...]]

optional arguments:
  -h, --help            show this help message and exit
  --audio_files AUDIO_FILES [AUDIO_FILES ...]
                        The speech signal to process
  --source_alignment_files SOURCE_ALIGNMENT_FILES [SOURCE_ALIGNMENT_FILES ...]
                        The files containing the original alignments
  --target_alignment_files TARGET_ALIGNMENT_FILES [TARGET_ALIGNMENT_FILES ...]
                        The files containing the target alignments
  --constant_stretch CONSTANT_STRETCH
                        A constant value for time-stretching
  --target_pitch_files TARGET_PITCH_FILES [TARGET_PITCH_FILES ...]
                        The target pitch contour
  --fmin FMIN           The minimum allowable frequency in Hz
  --fmax FMAX           The maximum allowable frequency in Hz
  --output_files OUTPUT_FILES [OUTPUT_FILES ...]
                        Where to save the vocoded audioReferences[1] Y. Jadoul, B. Thompson, and B. De Boer, "Introducing parselmouth: A python interface to praat," Journal of Phonetics, vol. 71, pp. 1â€“15, 2018.[2] P. Boersma, "Praat: doing phonetics by computer",http://www.praat.org/, 2006.[3] E. Moulines and F. Charpentier, "Pitch-synchronous waveform processing techniques for text-to-speech synthesis using diphones," Speech communication, 1990.