Skip to content

Subtitles Out Of Order #13

Open
Open
@Cynary

Description

@Cynary

What is the current behavior?

On some transcriptions, the produced SRT file has subtitles out of order.

Steps to reproduce

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

Expected behavior

The produced subtitle file should have in-order subtitles.

Please tell us about your environment

We want to make sure the problem isn't specific to your operating system or programming language.

  • Operating System/Version: Ubuntu 24.04
  • Language: Python
  • Browser: Chrome

Other information

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.

Here's my code:

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions