Created
July 13, 2016 10:09
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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