GithubHelp home page GithubHelp logo

emma-holmes / audio-scripts Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 56 KB

Miscallaneous scripts for auditory/hearing/speech research

License: GNU General Public License v3.0

MATLAB 100.00%
auditory hearing speech praat pitch audio matlab

audio-scripts's Introduction

Audio-Scripts

Miscallaneous scripts for auditory / hearing / speech research

  • BATCH_pitchShift
  • BATCH_durationShift
  • BATCH_normalise_RMS_amp
  • analyse_pitch
  • analyse_duration
  • plot_audiogram
  • calibrate_sound_level

License

These scripts are licensed under the GNU General Public License v3.0; see the LICENSE file for details.

BATCH_pitchShift

This script is designed for editing the pitch and formant spacing of audio files. The script will find all .wav files within the specified directory and create new versions of every file, which is saved in a new subdirectory (so you don't need to worry about overwriting files). When the script is run, it generates a form, which enables the user to specify the directory, the magnitude of the pitch shift (or 0 if no pitch shift), and the desired formant ratio (specify 1 to maintain original formant spacing).

The script gives users the option to specify the pitch shift in 5 different ways:

  1. Change the pitch by an absolute value in Hertz
  2. Change the pitch by a percentage (e.g. if you wanted a 20% increase or decrease in pitch)
  3. Change the pitch by a specified number of semitones
  4. Change the pitch by a specified number of ERBs (based on Glasberg & Moore, 1990, Hearing Research). I have implemented this by calculating the ERB at the average F0 of the original stimulus, then adding (or subtracting) this bandwidth, which becomes the average F0 of the new stimulus. If 2 ERBs are specified, then the script changes by 1 ERB, recalculates the ERB at the new F0, then modifies it by the new bandwidth.
  5. Specify a new pitch value in Hertz (e.g. 200 Hz)

    The magnitude of the pitch shift will depend on the method specified above. For example, if option (1) is selected, then entering 50 as an input will shift the pitch upwards by 50 Hz. To specify pitches lower than the original, enter a negative number.

Prerequisites

This script can be run using Praat, which can be installed from the following link: http://www.fon.hum.uva.nl/praat/
The script was tested using Praat version 6.0.36 for Windows.

Running the script

To use, download the BATCH_pitchShift script, open the script in Praat, then select Run from the toolbar.

BATCH_durationShift

This script is designed for editing the duration of audio files. The script will find all .wav files within the specified directory and create new versions of every file, which is saved in a new subdirectory (so you don't need to worry about overwriting files). When the script is run, it generates a form, which enables the user to specify the directory and the magnitude of the duration shift.

The script gives users the option to specify the duration shift in 3 different ways:

  1. Specify a new duration value in seconds (e.g. 1.6 seconds)
  2. Change the duration by an absolute value in seconds
  3. Change the duration by a percentage (e.g. if you wanted a 20% increase or decrease in duration)

    The magnitude of the duration shift will depend on the method specified above. For example, if option (2) is selected, then entering 0.5 as an input will increase the duration of the file by 0.5 seconds. To specify durations shorter than the original file, enter a negative number.

Prerequisites

This script can be run using Praat, which can be installed from the following link: http://www.fon.hum.uva.nl/praat/
The script was tested using Praat version 6.0.36 for Windows.

Running the script

To use, download the BATCH_durationShift script, open the script in Praat, then select Run from the toolbar.

BATCH_normalise_RMS_amp

This script takes all .wav files in a specified directory, normalises the RMS amplitude, and saves them into a new subdirectory.

Prerequisites

This is a MATLAB script, tested using MATLAB R2017a. The normalise_RMS_amp.m script should be in the MATLAB path.

Running the script

Use as:
BATCH_normalise_RMS_amp(DIR, RMS)

e.g.,
BATCH_normalise_RMS_amp(pwd, 0.05)

The script takes the following inputs:

Input Description
DIR String specifying the directory containing files to modify.
RMS RMS amplitude value (number between 0 and 1). Leave empty to display average RMS amplitude of files in directory before user input.

analyse_pitch

This script is designed for analysing the pitch of audio files. The script will find all .wav files within the specified directory and create a new text file in the directory, which contains a list of the median pitches of the files (in alphabetical order). When the script is run, it generates a form, which enables the user to specify the directory to analyse.

Prerequisites

This script can be run using Praat, which can be installed from the following link: http://www.fon.hum.uva.nl/praat/
The script was tested using Praat version 6.0.36 for Windows.

Running the script

To use, download the analyse_pitch script, open the script in Praat, then select Run from the toolbar.

analyse_duration

This script is designed for analysing the duration of audio files. The script will find all .wav files within the specified directory and create a new text file in the directory, which contains a list of the durations of the files (in alphabetical order). When the script is run, it generates a form, which enables the user to specify the directory to analyse.

Prerequisites

This script can be run using Praat, which can be installed from the following link: http://www.fon.hum.uva.nl/praat/
The script was tested using Praat version 6.0.36 for Windows.

Running the script

To use, download the analyse_duration script, open the script in Praat, then select Run from the toolbar.

plot_audiogram

This script plots audiometric thresholds on a graph. Plots worse frequencies towards the bottom of the graph.

Prerequisites

This is a MATLAB script, tested using MATLAB R2017a. The format_graph.m script should be in the MATLAB path.

Running the script

Use as:
hFig = plot_audiogram(hFig, freq, threshs, xLimits, yLimits, plotColour, ind_threshs, ind_colour, save_file)

e.g.,
hFig = plot_audiogram([], [250, 500, 1000, 2000, 4000, 8000], [5, 5, 5, 10, 5, 10], [200, 8050], [-10, 80], 'k', [], [], 'audiogram_plot')

The script takes the following inputs:

Input Description
hFig Handle for figure or axis. To create new, pass empty vector.
freq Vector containing frequencies to plot.
threshs Vector containing threshold values to plot.
xLimits 2-element vector containing upper and lower bounds of x-axis (frequencies). Default = [0, 8000].
yLimits 2-element vector containing upper and lower bounds of y-axis (thresholds). Default = [-10, 60].
plotColour MATLAB ColorSpec, e.g., 'r' or [1, 0, 0].
ind_threshs N x freq matrix specifying thresholds for individual participants to plot on graph. If empty, does not plot individual participants.
ind_colour N x 3 matrix of RGB color values, corresponding to the individual thresholds specified in ind_thresh.
save_file String containing filepath to save plot. If empty vector passed, plot not saved.

calibrate_sound_level

This script is designed as an aid for calibrating the level of acoustic stimuli with a sound level meter. When the script is run, it plays the desired sound and prompts the user to enter the reading from the sound level meter (in decibels). In automatic calibration mode, the script estimates the RMS level for sound playback to reach the desired decibel level. The script saves the RMS levels and sound level meter readings as an output file.

Prerequisites

This is a MATLAB script, tested using MATLAB R2017a. The calibrate_sound_level.m script should be in the MATLAB path. It is assumed that the user has access to a sound level meter to take readings.

Running the script

Use as:
calibrate_sound_level(wavFile, outFile, desired_level, start_rms)

e.g.,
calibrate_sound_level('calibration_stimulus.wav', 'calibration_outputs', 70, 0.05)

The script takes the following inputs:

Input Description
wavFile String specifying the filepath to the audio file used for calibration.
outFile String specifying the desired filename for the output file.
desired_level Desired sound level (in decibels) to calibrate to (e.g., 70).
start_rms RMS amplitude value (value between 0 and 1) to start the calibration. Leave empty to play the wavFile as is.

audio-scripts's People

Contributors

emma-holmes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.