Skip to content

Instantly share code, notes, and snippets.

@boeckhoff
Created July 13, 2016 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boeckhoff/6a1e6a5b88707fcbc0bb4d43ad206990 to your computer and use it in GitHub Desktop.
Save boeckhoff/6a1e6a5b88707fcbc0bb4d43ad206990 to your computer and use it in GitHub Desktop.
Script that helps with annotating audio files for training HMM Model for pyAudioAnalysis Segmentation
import time, sys
PATH_TO_FILE = sys.argv[1]
DICT = {"1": "speech",
"2": "laugther",
"3": "applause"}
quit = False
lCurrent = raw_input("Enter literal to start: ")
absolutStartTime = time.time()
startTime = absolutStartTime
while True:
lNext = raw_input("")
if lNext == "":
quit = True
endTime = time.time()
relativeEndTime = endTime - absolutStartTime
relativeStartTime = startTime - absolutStartTime
with open(PATH_TO_FILE, "a") as f:
f.write(str("%.2f" % relativeStartTime) + "," + str("%.2f" % relativeEndTime) + "," + DICT[lCurrent] + "\n")
f.close()
if quit == True:
break
startTime = time.time()
lCurrent = lNext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment