forked from karylab/liars-bar-game
20 lines
588 B
Python
20 lines
588 B
Python
from faster_whisper import WhisperModel
|
|
|
|
model = WhisperModel('medium', device='cpu', compute_type='int8')
|
|
|
|
videos = [
|
|
('video1_audio.mp3', 'video1_transcript.txt'),
|
|
('video2_audio.mp3', 'video2_transcript.txt'),
|
|
]
|
|
|
|
for inp, out in videos:
|
|
print(f'Starting: {inp}', flush=True)
|
|
segs, info = model.transcribe(inp, language='zh', beam_size=1)
|
|
segs = list(segs)
|
|
with open(out, 'w', encoding='utf-8') as f:
|
|
for seg in segs:
|
|
f.write(f'[{seg.start:.1f}s] {seg.text}\n')
|
|
print(f'Done: {out} ({len(segs)} segments)', flush=True)
|
|
|
|
print('ALL DONE')
|