From: Marcel Klehr Date: Fri, 30 Aug 2024 06:33:06 +0000 (+0200) Subject: fix(SpeechToTextManager): Throw TaskProcessing Task failed X-Git-Tag: v30.0.0rc4~38^2~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=578e576b89d7d60adbe4d07d706bb4da006d0c5e;p=nextcloud-server.git fix(SpeechToTextManager): Throw TaskProcessing Task failed Signed-off-by: Marcel Klehr Signed-off-by: Julien Veyssier --- diff --git a/lib/private/SpeechToText/SpeechToTextManager.php b/lib/private/SpeechToText/SpeechToTextManager.php index c4397112a18..d69add2d80b 100644 --- a/lib/private/SpeechToText/SpeechToTextManager.php +++ b/lib/private/SpeechToText/SpeechToTextManager.php @@ -120,22 +120,24 @@ class SpeechToTextManager implements ISpeechToTextManager { // try to run a TaskProcessing core:audio2text task // this covers scheduling as well because OC\SpeechToText\TranscriptionJob calls this method try { - $taskProcessingTask = new Task( - AudioToText::ID, - ['input' => $file->getId()], - $appId, - $userId, - 'from-SpeechToTextManager||' . $file->getId() . '||' . ($userId ?? '') . '||' . $appId, - ); - $resultTask = $this->taskProcessingManager->runTask($taskProcessingTask); - if ($resultTask->getStatus() === Task::STATUS_SUCCESSFUL) { - $output = $resultTask->getOutput(); - if (isset($output['output']) && is_string($output['output'])) { - return $output['output']; + if (isset($this->taskProcessingManager->getAvailableTaskTypes()['core:audio2text'])) { + $taskProcessingTask = new Task( + AudioToText::ID, + ['input' => $file->getId()], + $appId, + $userId, + 'from-SpeechToTextManager||' . $file->getId() . '||' . ($userId ?? '') . '||' . $appId, + ); + $resultTask = $this->taskProcessingManager->runTask($taskProcessingTask); + if ($resultTask->getStatus() === Task::STATUS_SUCCESSFUL) { + $output = $resultTask->getOutput(); + if (isset($output['output']) && is_string($output['output'])) { + return $output['output']; + } } } } catch (Throwable $e) { - $this->logger->debug('Failed to run a Speech-to-text job from STTManager with TaskProcessing for file ' . $file->getId(), ['exception' => $e]); + throw new RuntimeException('Failed to run a Speech-to-text job from STTManager with TaskProcessing for file ' . $file->getId(), 0, $e); } if (!$this->hasProviders()) {