]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(SpeechToTextManager): Throw TaskProcessing Task failed
authorMarcel Klehr <mklehr@gmx.net>
Fri, 30 Aug 2024 06:33:06 +0000 (08:33 +0200)
committerJulien Veyssier <julien-nc@posteo.net>
Fri, 30 Aug 2024 12:06:15 +0000 (14:06 +0200)
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
lib/private/SpeechToText/SpeechToTextManager.php

index c4397112a18156d3f276452f01c9233cfce9d84b..d69add2d80bea9bc0d6c843ade9482a771fad01d 100644 (file)
@@ -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()) {