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

Problem with changing <v speaker> to speaker: #61

Open
vnali opened this issue Jun 21, 2023 · 5 comments
Open

Problem with changing <v speaker> to speaker: #61

vnali opened this issue Jun 21, 2023 · 5 comments

Comments

@vnali
Copy link
Contributor

vnali commented Jun 21, 2023

Hi.
First of all thank you for this very useful class,
I am trying to pass a vtt string with <v speaker> in it to this class and then add a new line to it and return vtt format again.
the problem is vttConvertor changes <v speaker> to speaker: - in this case it should not, because i want the vtt format again -

I have also a related suggestion/solution:
Maybe instead of changing the speaker and adding it to the body in fileContentToInternalFormat function, we should keep parsed speakers for each line in a new key in $internal_format like

   (
        [start] => 137.44
        [end] => 140.375
        [lines] => Array
            (
                [0] => Senator, we're making
                [1] => our final approach
            )
        [speakers] => Array
            (
                [0] => speaker1
                [1] => speaker2 // or maybe no speaker
            )
    )

and decide later based on the destination format in internalFormatToFileContent function, how we want the speaker values in the body lines. -so in vttConverter we prepend it as to line[0] and on srtConverter we prepend it as speaker1:-

Another good reason for this is some new formats like html subtitles or json subtitles have another separate tag for speaker value and they don't include the speaker in the body lines at all.

@mantas-done
Copy link
Owner

Hi, thank you for the suggestions. At this point, I am trying to just support conversion between different formats without styles. And with limited time it would be too much work to add speaker support to all the converters and to properly test them.

@vnali
Copy link
Contributor Author

vnali commented Jun 22, 2023

Thank you @mantas-done
For fixing the issue as a workaround i used getInternalFormat() and setInternalFormat() like this to convert v: to <v></v> again

        $vtt = Subtitles::loadFromString($vttString, 'vtt');
        $internalFormat = $vtt->getInternalFormat();
        // loop through lines and convert `v:` to `<v></v>` again
            foreach ($internalFormat as $format) {
                foreach ($format['lines'] as $key => $line) {
                ....
                }
            }
        //
        $vtt->setInternalFormat($newInternalFormat);
        $vtt->add(....);
        $newVtt = $vtt->content('vtt');

@mantas-done
Copy link
Owner

Looking again at your issue. Your suggestion is actually very good. If you would be willing to implement storage of speakers in the internal_format, I would merge it.

@vnali
Copy link
Contributor Author

vnali commented Aug 22, 2023

@mantas-done
sure, I will take a look at the code to see if I can do it. I know how speaker appears on the srt and vtt subtitles but is there any reference about other formats?

@mantas-done
Copy link
Owner

mantas-done commented Aug 22, 2023 via email

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

2 participants