Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,11 @@ video_transcription:
# At least 1 remote runner must be configured to transcribe your videos
remote_runners:
enabled: false

# Size of transcription files to keep on your server
# If the transcription file is smaller than this size, PeerTube will delete it after transcription
# With this setting, you can limit the hallucinations of the transcription engine
limit_valid_transcription_size: 100

video_file:
update:
Expand Down
3 changes: 3 additions & 0 deletions server/core/initializers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,9 @@ const CONFIG = {
get MODEL_PATH () {
return config.get<string>('video_transcription.model_path')
},
get LIMIT_VALID_TRANSCRIPTION_SIZE () {
return config.get<number>('video_transcription.limit_valid_transcription_size')
},
REMOTE_RUNNERS: {
get ENABLED () {
return config.get<boolean>('video_transcription.remote_runners.enabled')
Expand Down
13 changes: 13 additions & 0 deletions server/core/lib/video-captions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import { Notifier } from './notifier/notifier.js'
import { TranscriptionJobHandler } from './runners/index.js'
import { VideoPathManager } from './video-path-manager.js'
import { promises as fs } from 'fs'

const lTags = loggerTagsFactory('video-caption')

Expand Down Expand Up @@ -213,6 +214,18 @@
lTags?: (string | number)[]
}) {
const { video, language, vttPath, lTags: customLTags = [] } = options
var limitValideTranscriptionSize = CONFIG.VIDEO_TRANSCRIPTION.LIMIT_VALID_TRANSCRIPTION_SIZE || 100

Check failure on line 217 in server/core/lib/video-captions.ts

View workflow job for this annotation

GitHub Actions / test (lint)

Unexpected var, use let or const instead

Check failure on line 217 in server/core/lib/video-captions.ts

View workflow job for this annotation

GitHub Actions / test (lint)

Unexpected var, use let or const instead

try {
const stats = await fs.stat(vttPath)
if (stats.size < limitValideTranscriptionSize) {
logger.info(`Transcription file ${vttPath} is too small, do not create caption for video ${video.uuid}`)
return
}
} catch (err) {
logger.error(`Error while checking transcription file ${vttPath} for video ${video.uuid}`, { err })
return
}

if (!isVideoCaptionLanguageValid(language)) {
logger.warn(`Invalid transcription language for video ${video.uuid}`, lTags(video.uuid))
Expand Down
Loading