On some transcriptions, the produced SRT file has subtitles out of order.
I have a small ogg file that I transcribed using nova-2, and then passed to the captions library, which generated this error. For convenience I included the json output (it's in japanese), the final srt, and the sound file (to bypass github's upload limitations, I used a .txt extension, but it's originally a .ogg file).
IMAX PR Video.json
sub.txt
sound.txt
The produced subtitle file should have in-order subtitles.
Looking at the JSON output, it looks like the words are just returned out of order, but the converter assumes they're in order. Looking at the subtitles themselves, it actually almost looks like deepgram translated multiple times in some weird way. My initial thought was to just sort the words by start time, but when I translate the results of that, there's a bit of overlap still. It's almost as if deepgram is returning multiple alternative translations at once, or maybe different streams. It's almost as if diarization is happening, even though I didn't use it through the API.
def main():
try:
# STEP 1 Create a Deepgram client using the API key
deepgram = DeepgramClient(API_KEY)
with open(AUDIO_FILE, "rb") as file:
buffer_data = file.read()
payload: FileSource = {
"buffer": buffer_data,
}
#STEP 2: Configure Deepgram options for audio analysis
options = PrerecordedOptions(
model="nova-2",
smart_format=True,
language=LANG,
)
print("Transcribing")
# STEP 3: Call the transcribe_file method with the text payload and options
response = deepgram.listen.prerecorded.v("1").transcribe_file(payload, options)
# Step 4: transcribe to SRT.
transcription = DeepgramConverter(response)
captions = srt(transcription)
with open(f"{basename}.{LANG}.srt", 'w') as f:
print(captions, file=f)