diff options
author | Marcel Klehr <mklehr@gmx.net> | 2024-08-30 08:33:06 +0200 |
---|---|---|
committer | Julien Veyssier <julien-nc@posteo.net> | 2024-08-30 10:07:01 +0200 |
commit | de117d4654f7158007fe8ef2308a04796cd27701 (patch) | |
tree | 4314f504b77cdd60e043c296ddc7583b219a89a2 /lib | |
parent | 7be3a18f13aff1382f0830319f81ab85358ecc05 (diff) | |
download | nextcloud-server-de117d4654f7158007fe8ef2308a04796cd27701.tar.gz nextcloud-server-de117d4654f7158007fe8ef2308a04796cd27701.zip |
fix(SpeechToTextManager): Throw TaskProcessing Task failed
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/SpeechToText/SpeechToTextManager.php | 28 |
1 files changed, 15 insertions, 13 deletions
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()) { |