Skip to content
Merged
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
11 changes: 11 additions & 0 deletions lib/Service/OpenAiAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,17 @@ public function transcribe(
if (isset($response['segments'])) {
$audioDuration = intval(round(floatval(array_pop($response['segments'])['end'])));

if ($audioDuration < 0) {
$this->logger->warning('Audio duration is less than 0: ' . $audioDuration);
$audioDuration = 0;
}

// Audio durations higher than this can cause errors in the database: https://github.com/nextcloud/integration_openai/issues/394
if ($audioDuration > 2147483647) {
$this->logger->warning('Audio duration is greater than 2147483647 seconds: ' . $audioDuration);
$audioDuration = 2147483647;
}
Comment thread
lukasdotcom marked this conversation as resolved.

try {
$this->createQuotaUsage($userId ?? '', Application::QUOTA_TYPE_TRANSCRIPTION, $audioDuration);
} catch (DBException $e) {
Expand Down
Loading