aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/SpeechToText
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2023-04-17 14:45:18 +0200
committerMarcel Klehr <mklehr@gmx.net>2023-04-17 14:57:19 +0200
commit71523b9816b1162f30ca8d682b8d410edc6d9cfc (patch)
treec2ad4b9bd0b26c1a932e17f0cf6df8ac7bf4fc46 /lib/private/SpeechToText
parentad66180c3404045e4ae15e9b3a895b50a69efd75 (diff)
downloadnextcloud-server-71523b9816b1162f30ca8d682b8d410edc6d9cfc.tar.gz
nextcloud-server-71523b9816b1162f30ca8d682b8d410edc6d9cfc.zip
AbstractTranscriptionEvent: Add File param
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib/private/SpeechToText')
-rw-r--r--lib/private/SpeechToText/TranscriptionJob.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/private/SpeechToText/TranscriptionJob.php b/lib/private/SpeechToText/TranscriptionJob.php
index d8abf9a9c34..fd175e774a5 100644
--- a/lib/private/SpeechToText/TranscriptionJob.php
+++ b/lib/private/SpeechToText/TranscriptionJob.php
@@ -35,6 +35,7 @@ use OCP\PreConditionNotMetException;
use OCP\SpeechToText\Events\TranscriptionFailedEvent;
use OCP\SpeechToText\Events\TranscriptionSuccessfulEvent;
use OCP\SpeechToText\ISpeechToTextManager;
+use Psr\Log\LoggerInterface;
class TranscriptionJob extends QueuedJob {
public function __construct(
@@ -42,6 +43,7 @@ class TranscriptionJob extends QueuedJob {
private ISpeechToTextManager $speechToTextManager,
private IEventDispatcher $eventDispatcher,
private IRootFolder $rootFolder,
+ private LoggerInterface $logger,
) {
parent::__construct($timeFactory);
}
@@ -52,12 +54,15 @@ class TranscriptionJob extends QueuedJob {
*/
protected function run($argument) {
$fileId = $argument['fileId'];
+ $file = null;
try {
$file = current($this->rootFolder->getById($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',
)
);
@@ -67,13 +72,16 @@ class TranscriptionJob extends QueuedJob {
$this->eventDispatcher->dispatchTyped(
new TranscriptionSuccessfulEvent(
$fileId,
+ $file,
$result,
)
);
} catch (PreConditionNotMetException|\RuntimeException|\InvalidArgumentException $e) {
+ $this->logger->warning('Transcription of file ' . $fileId . ' failed', ['exception' => $e]);
$this->eventDispatcher->dispatchTyped(
new TranscriptionFailedEvent(
$fileId,
+ $file,
$e->getMessage(),
)
);