Metadata to know if the caption is auto generated

This commit is contained in:
Chocobozzz
2024-06-27 15:29:26 +02:00
parent 1bfb791e05
commit fd4831e502
22 changed files with 101 additions and 29 deletions

View File

@@ -4,6 +4,7 @@ export * from './cache-file-object.js'
export * from './common-objects.js'
export * from './playlist-element-object.js'
export * from './playlist-object.js'
export * from './video-caption-object.js'
export * from './video-chapters-object.js'
export * from './video-comment-object.js'
export * from './video-object.js'

View File

@@ -0,0 +1,5 @@
import { ActivityIdentifierObject } from './common-objects.js'
export interface VideoCaptionObject extends ActivityIdentifierObject {
automaticallyGenerated: boolean
}

View File

@@ -6,6 +6,7 @@ import {
ActivityTagObject,
ActivityUrlObject
} from './common-objects.js'
import { VideoCaptionObject } from './video-caption-object.js'
import { VideoChapterObject } from './video-chapters-object.js'
export interface VideoObject {
@@ -18,7 +19,7 @@ export interface VideoObject {
category: ActivityIdentifierObject
licence: ActivityIdentifierObject
language: ActivityIdentifierObject
subtitleLanguage: ActivityIdentifierObject[]
subtitleLanguage: VideoCaptionObject[]
views: number

View File

@@ -73,6 +73,7 @@ export interface VideoExportJSON {
language: string
filename: string
fileUrl: string
automaticallyGenerated: boolean
}[]
chapters: {

View File

@@ -3,5 +3,6 @@ import { VideoConstant } from '../video-constant.model.js'
export interface VideoCaption {
language: VideoConstant<string>
captionPath: string
automaticallyGenerated: boolean
updatedAt: string
}

View File

@@ -7,7 +7,7 @@
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"install-dependencies:transcription": "pip install -r ./requirements.txt ../transcription-devtools/requirements.txt"
"install-dependencies:transcription": "pip install -r ./requirements.txt -r ../transcription-devtools/requirements.txt"
},
"dependencies": {}
}

View File

@@ -72,12 +72,14 @@ describe('Test video captions', function () {
expect(caption1.language.id).to.equal('ar')
expect(caption1.language.label).to.equal('Arabic')
expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
expect(caption1.automaticallyGenerated).to.be.false
await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 1.')
const caption2 = body.data[1]
expect(caption2.language.id).to.equal('zh')
expect(caption2.language.label).to.equal('Chinese')
expect(caption2.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$'))
expect(caption1.automaticallyGenerated).to.be.false
await testCaptionFile(server.url, caption2.captionPath, 'Subtitle good 2.')
}
})

View File

@@ -13,7 +13,7 @@ import {
waitJobs
} from '@peertube/peertube-server-commands'
import { FIXTURE_URLS } from '@tests/shared/fixture-urls.js'
import { checkCaption, checkLanguage, checkNoCaption, uploadForTranscription } from '@tests/shared/transcription.js'
import { checkAutoCaption, checkLanguage, checkNoCaption, uploadForTranscription } from '@tests/shared/transcription.js'
describe('Test video transcription', function () {
let servers: PeerTubeServer[]
@@ -48,7 +48,7 @@ describe('Test video transcription', function () {
await waitJobs(servers)
await checkLanguage(servers, uuid, 'en')
await checkCaption(servers, uuid)
await checkAutoCaption(servers, uuid)
})
it('Should run transcription on upload by default', async function () {
@@ -57,7 +57,7 @@ describe('Test video transcription', function () {
const uuid = await uploadForTranscription(servers[0])
await waitJobs(servers)
await checkCaption(servers, uuid)
await checkAutoCaption(servers, uuid)
await checkLanguage(servers, uuid, 'en')
})
@@ -73,7 +73,7 @@ describe('Test video transcription', function () {
})
await waitJobs(servers)
await checkCaption(servers, video.uuid)
await checkAutoCaption(servers, video.uuid)
await checkLanguage(servers, video.uuid, 'en')
})
@@ -96,7 +96,7 @@ describe('Test video transcription', function () {
await servers[0].live.waitUntilReplacedByReplay({ videoId: video.id })
await waitJobs(servers)
await checkCaption(servers, video.uuid, 'WEBVTT\n\n00:')
await checkAutoCaption(servers, video.uuid, 'WEBVTT\n\n00:')
await checkLanguage(servers, video.uuid, 'en')
await servers[0].config.enableLive({ allowReplay: false })

View File

@@ -13,7 +13,7 @@ import {
} from '@peertube/peertube-server-commands'
import { checkPeerTubeRunnerCacheIsEmpty } from '@tests/shared/directories.js'
import { PeerTubeRunnerProcess } from '@tests/shared/peertube-runner-process.js'
import { checkCaption, checkLanguage, checkNoCaption, uploadForTranscription } from '@tests/shared/transcription.js'
import { checkAutoCaption, checkLanguage, checkNoCaption, uploadForTranscription } from '@tests/shared/transcription.js'
describe('Test transcription in peertube-runner program', function () {
let servers: PeerTubeServer[] = []
@@ -46,7 +46,7 @@ describe('Test transcription in peertube-runner program', function () {
const uuid = await uploadForTranscription(servers[0])
await waitJobs(servers, { runnerJobs: true })
await checkCaption(servers, uuid)
await checkAutoCaption(servers, uuid)
await checkLanguage(servers, uuid, 'en')
})

View File

@@ -28,7 +28,7 @@ export function getCustomModelPath (modelName: CustomModelName) {
// ---------------------------------------------------------------------------
export async function checkCaption (servers: PeerTubeServer[], uuid: string, captionContains = 'WEBVTT\n\n00:00.000 --> 00:') {
export async function checkAutoCaption (servers: PeerTubeServer[], uuid: string, captionContains = 'WEBVTT\n\n00:00.000 --> 00:') {
for (const server of servers) {
const body = await server.captions.list({ videoId: uuid })
expect(body.total).to.equal(1)
@@ -37,6 +37,7 @@ export async function checkCaption (servers: PeerTubeServer[], uuid: string, cap
const caption = body.data[0]
expect(caption.language.id).to.equal('en')
expect(caption.language.label).to.equal('English')
expect(caption.automaticallyGenerated).to.be.true
{
await testCaptionFile(server.url, caption.captionPath, captionContains)