json-cache whisper transcription

This commit is contained in:
2025-09-22 14:52:18 -05:00
parent cc261b3a72
commit f09945213e

View File

@@ -4,6 +4,8 @@ usage = 'python transcribe-voice-track.py <fountain filename> <character> <wav f
import util
from imports import *
import json
from os.path import exists
import whisper
model = whisper.load_model("turbo")
@@ -80,7 +82,15 @@ map = fmap.map
print(map)
for audio_filename in audio_filenames:
result = model.transcribe(audio_filename)
result = None
if exists(f'{audio_filename}.json'):
with open(f'{audio_filename}.json', 'r') as f:
result = json.load(f)
else:
result = model.transcribe(audio_filename)
with open(f'{audio_filename}.json', 'w') as f:
json.dump(result, f)
print(result['segments'])
for segment in result['segments']:
match = fmap.best_match(segment['text'])