aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/SpeechToText
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2023-04-13 12:12:07 +0200
committerMarcel Klehr <mklehr@gmx.net>2023-04-13 12:12:07 +0200
commita8d3fff648c4c6f5be3e37c09f9168e5b7c0e8f8 (patch)
tree6115b6748d00997155016d708879e796bfe21344 /lib/public/SpeechToText
parent176f1af26a6bf7c62cadd04448b73839296653c0 (diff)
downloadnextcloud-server-a8d3fff648c4c6f5be3e37c09f9168e5b7c0e8f8.tar.gz
nextcloud-server-a8d3fff648c4c6f5be3e37c09f9168e5b7c0e8f8.zip
Split TranscriptionFinishedEvent into Successful and Failed events
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib/public/SpeechToText')
-rw-r--r--lib/public/SpeechToText/Events/AbstractTranscriptionEvent.php (renamed from lib/public/SpeechToText/Events/TranscriptionFinishedEvent.php)32
-rw-r--r--lib/public/SpeechToText/Events/TranscriptionFailedEvent.php24
-rw-r--r--lib/public/SpeechToText/Events/TranscriptionSuccessfulEvent.php26
3 files changed, 54 insertions, 28 deletions
diff --git a/lib/public/SpeechToText/Events/TranscriptionFinishedEvent.php b/lib/public/SpeechToText/Events/AbstractTranscriptionEvent.php
index 245ccd413e9..5b00315f74c 100644
--- a/lib/public/SpeechToText/Events/TranscriptionFinishedEvent.php
+++ b/lib/public/SpeechToText/Events/AbstractTranscriptionEvent.php
@@ -30,15 +30,12 @@ use OCP\EventDispatcher\Event;
/**
* @since 27.0.0
*/
-class TranscriptionFinishedEvent extends Event {
+abstract class AbstractTranscriptionEvent extends Event {
/**
* @since 27.0.0
*/
public function __construct(
- private bool $successful,
- private string $transcription,
- private string $errorMessage,
- private array $context
+ private int $fileIdId
) {
parent::__construct();
}
@@ -46,28 +43,7 @@ class TranscriptionFinishedEvent extends Event {
/**
* @since 27.0.0
*/
- public function getContext(): array {
- return $this->context;
- }
-
- /**
- * @since 27.0.0
- */
- public function isSuccessful(): bool {
- return $this->successful;
- }
-
- /**
- * @since 27.0.0
- */
- public function getErrorMessage(): string {
- return $this->errorMessage;
- }
-
- /**
- * @since 27.0.0
- */
- public function getTranscription(): string {
- return $this->transcription;
+ public function getFileId(): int {
+ return $this->fileIdId;
}
}
diff --git a/lib/public/SpeechToText/Events/TranscriptionFailedEvent.php b/lib/public/SpeechToText/Events/TranscriptionFailedEvent.php
new file mode 100644
index 00000000000..3a490995c10
--- /dev/null
+++ b/lib/public/SpeechToText/Events/TranscriptionFailedEvent.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace OCP\SpeechToText\Events;
+
+class TranscriptionFailedEvent extends AbstractTranscriptionEvent {
+
+ /**
+ * @since 27.0.0
+ */
+ public function __construct(
+ int $fileId,
+ private string $errorMessage
+ ) {
+ parent::__construct($fileId);
+ }
+
+ /**
+ * @since 27.0.0
+ * @return string The error message
+ */
+ public function getErrorMessage(): string {
+ return $this->errorMessage;
+ }
+}
diff --git a/lib/public/SpeechToText/Events/TranscriptionSuccessfulEvent.php b/lib/public/SpeechToText/Events/TranscriptionSuccessfulEvent.php
new file mode 100644
index 00000000000..63644b98f6d
--- /dev/null
+++ b/lib/public/SpeechToText/Events/TranscriptionSuccessfulEvent.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace OCP\SpeechToText\Events;
+
+use OCP\Files\File;
+
+class TranscriptionSuccessfulEvent extends AbstractTranscriptionEvent {
+
+ /**
+ * @since 27.0.0
+ */
+ public function __construct(
+ int $fileId,
+ private string $transcript
+ ) {
+ parent::__construct($fileId);
+ }
+
+ /**
+ * @since 27.0.0
+ * @return string The transcript of the media file
+ */
+ public function getTranscript(): string {
+ return $this->transcript;
+ }
+}