Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtitles Out Of Order #13

Open
Cynary opened this issue May 10, 2024 · 0 comments
Open

Subtitles Out Of Order #13

Cynary opened this issue May 10, 2024 · 0 comments

Comments

@Cynary
Copy link

Cynary commented May 10, 2024

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant