Don't replace caption on transcription

This commit is contained in:
Chocobozzz 2024-07-12 16:20:26 +02:00
parent 60a424059d
commit 300676f62b
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 26 additions and 0 deletions

View File

@ -146,6 +146,22 @@ describe('Test video transcription', function () {
await checkLanguage(servers, uuid, null) await checkLanguage(servers, uuid, null)
}) })
it('Should not replace an existing caption', async function () {
const uuid = await uploadForTranscription(servers[0])
await servers[0].captions.add({
language: 'en',
videoId: uuid,
fixture: 'subtitle-good1.vtt'
})
const contentBefore = await getCaptionContent(servers[0], uuid, 'en')
await waitJobs(servers)
const contentAter = await getCaptionContent(servers[0], uuid, 'en')
expect(contentBefore).to.equal(contentAter)
})
it('Should run transcription after a video edition', async function () { it('Should run transcription after a video edition', async function () {
this.timeout(120000) this.timeout(120000)

View File

@ -154,6 +154,16 @@ export async function onTranscriptionEnded (options: {
await video.save() await video.save()
} }
const existing = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
if (existing && !existing.automaticallyGenerated) {
logger.info(
// eslint-disable-next-line max-len
`Do not replace existing caption for video ${video.uuid} after transcription (subtitle may have been added while during the transcription process)`,
lTags(video.uuid)
)
return
}
const caption = await createLocalCaption({ const caption = await createLocalCaption({
video, video,
language, language,