"""Run Akiki VAD using the engine and weights bundled with the akiki package.""" import argparse from dataclasses import asdict import json import soundfile as sf from akiki import VAD def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('audio', help='Local mono 16 kHz recording') parser.add_argument('--threshold', type=float, default=None) args = parser.parse_args() with sf.SoundFile(args.audio) as source: if source.channels != 1 or source.samplerate != 16000: raise ValueError('Expected mono 16 kHz audio') with VAD(threshold=args.threshold) as detector: for block in source.blocks(blocksize=16000, dtype='float32'): for frame in detector.push(block, sample_rate=source.samplerate): print(json.dumps(asdict(frame))) if __name__ == '__main__': main()