setAllowParallelRuns(false); } /** * @inheritDoc */ protected function run($argument) { $fileId = $argument['fileId']; $owner = $argument['owner']; $userId = $argument['userId']; $appId = $argument['appId']; $file = null; try { \OC_Util::setupFS($owner); $userFolder = $this->rootFolder->getUserFolder($owner); $file = $userFolder->getFirstNodeById($fileId); if (!($file instanceof File)) { $this->logger->warning('Transcription of file ' . $fileId . ' failed. The file could not be found'); $this->eventDispatcher->dispatchTyped( new TranscriptionFailedEvent( $fileId, null, 'File not found', $userId, $appId, ) ); return; } $result = $this->speechToTextManager->transcribeFile($file, $userId, $appId); $this->eventDispatcher->dispatchTyped( new TranscriptionSuccessfulEvent( $fileId, $file, $result, $userId, $appId, ) ); } catch (PreConditionNotMetException|\RuntimeException|\InvalidArgumentException|NotFoundException|NotPermittedException|NoUserException $e) { $this->logger->warning('Transcription of file ' . $fileId . ' failed', ['exception' => $e]); $this->eventDispatcher->dispatchTyped( new TranscriptionFailedEvent( $fileId, $file, $e->getMessage(), $userId, $appId, ) ); } } }