forked from marsbroshok/VAD-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetectVoiceInWave.py
More file actions
22 lines (18 loc) · 871 Bytes
/
detectVoiceInWave.py
File metadata and controls
22 lines (18 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from vad import VoiceActivityDetector
import argparse
import json
def save_to_file(data, filename):
with open(filename, 'w') as fp:
json.dump(data, fp)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Analyze input wave-file and save detected speech interval to json file.')
parser.add_argument('inputfile', metavar='INPUTWAVE',
help='the full path to input wave file')
parser.add_argument('outputfile', metavar='OUTPUTFILE',
help='the full path to output json file to save detected speech intervals')
args = parser.parse_args()
v = VoiceActivityDetector(args.inputfile)
raw_detection = v.detect_speech()
speech_labels = v.convert_windows_to_readible_labels(raw_detection)
print(speech_labels)
save_to_file(speech_labels, args.outputfile)