diff options
author | Julien Veyssier <julien-nc@posteo.net> | 2024-02-27 11:27:40 +0100 |
---|---|---|
committer | Julien Veyssier <julien-nc@posteo.net> | 2024-03-15 12:52:17 +0100 |
commit | 76925f15d6d416dd340994b79d921f9d88eae603 (patch) | |
tree | ca8df7f1832acefdab4873ebaa6a8e0ac297c28c /lib/private/SpeechToText | |
parent | df1cd1ba7e6e1f6e66a2b3229b5c082f1b81162e (diff) | |
download | nextcloud-server-76925f15d6d416dd340994b79d921f9d88eae603.tar.gz nextcloud-server-76925f15d6d416dd340994b79d921f9d88eae603.zip |
feat(stt): add ability to cancel a scheduled transcription
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'lib/private/SpeechToText')
-rw-r--r-- | lib/private/SpeechToText/SpeechToTextManager.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/private/SpeechToText/SpeechToTextManager.php b/lib/private/SpeechToText/SpeechToTextManager.php index 73efe105b38..10944a0b424 100644 --- a/lib/private/SpeechToText/SpeechToTextManager.php +++ b/lib/private/SpeechToText/SpeechToTextManager.php @@ -112,6 +112,24 @@ class SpeechToTextManager implements ISpeechToTextManager { } } + public function cancelScheduledFileTranscription(File $file, ?string $userId, string $appId): void { + try { + $jobArguments = [ + 'fileId' => $file->getId(), + 'owner' => $file->getOwner()->getUID(), + 'userId' => $userId, + 'appId' => $appId, + ]; + if (!$this->jobList->has(TranscriptionJob::class, $jobArguments)) { + $this->logger->debug('Failed to cancel a Speech-to-text job for file ' . $file->getId() . '. No related job was found.'); + return; + } + $this->jobList->remove(TranscriptionJob::class, $jobArguments); + } catch (NotFoundException|InvalidPathException $e) { + throw new InvalidArgumentException('Invalid file provided to cancel file transcription: ' . $e->getMessage()); + } + } + public function transcribeFile(File $file): string { if (!$this->hasProviders()) { throw new PreConditionNotMetException('No SpeechToText providers have been registered'); |