Skip to content

Commit 00f8dcc

Browse files
committed
feat: add user facing errors in AudioToTextSubtitles provider
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 7e06c3b commit 00f8dcc

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

lib/TaskProcessing/AudioToTextSubtitlesProvider.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,22 @@ public function process(?string $userId, array $input, callable $reportProgress)
114114
$fileSize = intval($input['input']->getSize());
115115
// Maximum file size for OpenAI is 25MB. (https://developers.openai.com/api/docs/guides/speech-to-text)
116116
if ($fileSize > 25 * 1000 * 1000) {
117-
throw new ProcessingException('Filesize of input too large. Max is 25MB');
117+
throw new UserFacingProcessingException(
118+
'Filesize of input is too large. Max is 25MB',
119+
0,
120+
null,
121+
$this->l->t('The input file size is too large. A maximum of 25MB is allowed.'),
122+
);
118123
}
119124

120125
$fileType = $input['input']->getMimeType();
121126
if (!str_starts_with($fileType, 'audio/')) {
122-
throw new ProcessingException('Invalid input file type ' . $fileType);
127+
throw new UserFacingProcessingException(
128+
'Invalid input file type ' . $fileType,
129+
0,
130+
null,
131+
$this->l->t('The input file type is invalid. Only audio files are allowed.'),
132+
);
123133
}
124134
if ($this->openAiAPIService->isUsingOpenAi()) {
125135
$validFileTypes = [

0 commit comments

Comments
 (0)