aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/settings/lib/Settings/Admin/ArtificialIntelligence.php3
-rw-r--r--lib/private/SpeechToText/SpeechToTextManager.php10
-rw-r--r--lib/public/SpeechToText/ISpeechToTextProviderWithId.php14
3 files changed, 24 insertions, 3 deletions
diff --git a/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php b/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php
index 0af82a74c5e..8a283ba1e70 100644
--- a/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php
+++ b/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php
@@ -31,6 +31,7 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\Settings\IDelegatedSettings;
use OCP\SpeechToText\ISpeechToTextManager;
+use OCP\SpeechToText\ISpeechToTextProviderWithId;
use OCP\TextProcessing\IManager;
use OCP\TextProcessing\IProvider;
use OCP\TextProcessing\ITaskType;
@@ -69,7 +70,7 @@ class ArtificialIntelligence implements IDelegatedSettings {
$sttProviders = [];
foreach ($this->sttManager->getProviders() as $provider) {
$sttProviders[] = [
- 'class' => $provider::class,
+ 'class' => $provider instanceof ISpeechToTextProviderWithId ? $provider->getId() : $provider::class,
'name' => $provider->getName(),
];
}
diff --git a/lib/private/SpeechToText/SpeechToTextManager.php b/lib/private/SpeechToText/SpeechToTextManager.php
index bdd04ad3651..520700cf198 100644
--- a/lib/private/SpeechToText/SpeechToTextManager.php
+++ b/lib/private/SpeechToText/SpeechToTextManager.php
@@ -39,6 +39,7 @@ use OCP\IServerContainer;
use OCP\PreConditionNotMetException;
use OCP\SpeechToText\ISpeechToTextManager;
use OCP\SpeechToText\ISpeechToTextProvider;
+use OCP\SpeechToText\ISpeechToTextProviderWithId;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
@@ -117,8 +118,13 @@ class SpeechToTextManager implements ISpeechToTextManager {
$json = $this->config->getAppValue('core', 'ai.stt_provider', '');
if ($json !== '') {
- $className = json_decode($json, true);
- $provider = current(array_filter($providers, fn ($provider) => $provider::class === $className));
+ $classNameOrId = json_decode($json, true);
+ $provider = current(array_filter($providers, function ($provider) use ($classNameOrId) {
+ if ($provider instanceof ISpeechToTextProviderWithId) {
+ return $provider->getId() === $classNameOrId;
+ }
+ return $provider::class === $classNameOrId;
+ }));
if ($provider !== false) {
$providers = [$provider];
}
diff --git a/lib/public/SpeechToText/ISpeechToTextProviderWithId.php b/lib/public/SpeechToText/ISpeechToTextProviderWithId.php
new file mode 100644
index 00000000000..0fb337f4602
--- /dev/null
+++ b/lib/public/SpeechToText/ISpeechToTextProviderWithId.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace OCP\SpeechToText;
+
+/**
+ * @since 28.0.0
+ */
+interface ISpeechToTextProviderWithId extends ISpeechToTextProvider {
+
+ /**
+ * @since 28.0.0
+ */
+ public function getId(): string;
+}