Avoid adding tail padding for VAD in generate-subtitles.py (#1674)
This commit is contained in:
@@ -516,16 +516,13 @@ def main():
|
|||||||
|
|
||||||
is_eof = False
|
is_eof = False
|
||||||
# TODO(fangjun): Support multithreads
|
# TODO(fangjun): Support multithreads
|
||||||
while True:
|
while not is_eof:
|
||||||
# *2 because int16_t has two bytes
|
# *2 because int16_t has two bytes
|
||||||
data = process.stdout.read(frames_per_read * 2)
|
data = process.stdout.read(frames_per_read * 2)
|
||||||
if not data:
|
if not data:
|
||||||
if is_eof:
|
vad.flush()
|
||||||
break
|
|
||||||
is_eof = True
|
is_eof = True
|
||||||
# pad 1 second at the end of the file for the VAD
|
else:
|
||||||
data = np.zeros(1 * args.sample_rate, dtype=np.int16)
|
|
||||||
|
|
||||||
samples = np.frombuffer(data, dtype=np.int16)
|
samples = np.frombuffer(data, dtype=np.int16)
|
||||||
samples = samples.astype(np.float32) / 32768
|
samples = samples.astype(np.float32) / 32768
|
||||||
|
|
||||||
@@ -536,9 +533,6 @@ def main():
|
|||||||
vad.accept_waveform(buffer[:window_size])
|
vad.accept_waveform(buffer[:window_size])
|
||||||
buffer = buffer[window_size:]
|
buffer = buffer[window_size:]
|
||||||
|
|
||||||
if is_eof:
|
|
||||||
vad.flush()
|
|
||||||
|
|
||||||
streams = []
|
streams = []
|
||||||
segments = []
|
segments = []
|
||||||
while not vad.empty():
|
while not vad.empty():
|
||||||
|
|||||||
Reference in New Issue
Block a user