Skip to content

Instantly share code, notes, and snippets.

@erzk
erzk / split_continuous_audio.py
Created February 24, 2019 19:49
Split continuous audio files on occurrence of silence
#!/usr/bin/env python
import glob, os
for file in sorted(glob.glob("*.wav")):
print("#"*40)
print(file)
os.system("python audioAnalysis.py silenceRemoval -i " + file + " --smoothing 0.2 --weight 0.1")
@erzk
erzk / praat_pitch_analysis.R
Created February 11, 2019 00:57
Extract pitch values, intensity, time, and confidence from Praat pitch files
#!/usr/bin/env r
## load pitch files extracted from Praat and pull key information
# take input from the command line
f <- argv
# load packages and hide messages
library(dplyr)
library(rPraat)
@erzk
erzk / extract_pitch_script.praat
Created February 10, 2019 23:36
Extract pitch values, intensity, time, and confidence from all wav files in the working directory
clearinfo
# uncomment for a point-and-click version (then the next two lines should be commented out)
#inDir$ = chooseDirectory$: "Choose the folder containing your wav files"
wd$ = "./"
inDir$ = wd$
# create a list of all wav files in the chosen directory
inDirWild$ = inDir$ + "*.wav"
library(RCurl)
# download the R code
script <- getURL("https://raw.githubusercontent.com/usagi5886/dsp/master/Spectrogram().r",
ssl.verifypeer = FALSE)
# load it as a function
eval(parse(text = script))
library(audio)
# download the wav file
library(hht)
data(PortFosterEvent)
dt <- mean(diff(tt))
ft <- list()
ft$nfft <- 4096
ft$ns <- 30
ft$nov <- 29
library(warbleR)
# load and save data
data(list = c("Phae.long1", "Phae.long2","selec.table"))
writeWave(Phae.long1, "Phae.long1.wav")
# make spectrograms (saves the files in the working directory)
specreator(X = selec.table, flim = c(0, 11), res = 300, mar = 0.05, wl = 300)
library(soundgen)
# synthesize a sound 1 s long, with gradually increasing hissing noise
sound = soundgen(sylLen = 1000,
temperature = 0.001,
noiseAnchors = list(
time = c(0, 1300),
value = c(-120, 0)),
formantsNoise = list(
f1 = list(
library(signal)
specgram(chirp(seq(-2, 15, by = 0.001), 400, 10, 100, 'quadratic'))
library(ggplot2)
## first layer
v <- ggspectro(tico, ovlp = 50)
## using geom_tile ##
v + geom_tile(aes(fill = amplitude)) + stat_contour()
library(seewave)
data(tico)
spectro(tico)