aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/SpeechToText
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2023-04-17 16:58:14 +0200
committerMarcel Klehr <mklehr@gmx.net>2023-04-17 16:59:46 +0200
commit3f57725a7c68bd90b281a3f97639270cad25b072 (patch)
tree3df67ca9cb4ba65fc74a14e27e20158b714fb67c /lib/private/SpeechToText
parent47cff5d651653da5c7cde1ea2eccaccca2f2add1 (diff)
downloadnextcloud-server-3f57725a7c68bd90b281a3f97639270cad25b072.tar.gz
nextcloud-server-3f57725a7c68bd90b281a3f97639270cad25b072.zip
SpeechToTextManager#transcribeFile: Try next provider if one fails
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib/private/SpeechToText')
-rw-r--r--lib/private/SpeechToText/SpeechToTextManager.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/private/SpeechToText/SpeechToTextManager.php b/lib/private/SpeechToText/SpeechToTextManager.php
index 0c41c3cb600..146d7f8f8b1 100644
--- a/lib/private/SpeechToText/SpeechToTextManager.php
+++ b/lib/private/SpeechToText/SpeechToTextManager.php
@@ -101,16 +101,18 @@ class SpeechToTextManager implements ISpeechToTextManager {
}
public function transcribeFile(File $file): string {
- $provider = current($this->getProviders());
- if (!$provider) {
+ if (!$this->hasProviders()) {
throw new PreConditionNotMetException('No SpeechToText providers have been registered');
}
- try {
- return $provider->transcribeFile($file);
- } catch (\Throwable $e) {
- $this->logger->info('SpeechToText transcription failed', ['exception' => $e]);
- throw new \RuntimeException('SpeechToText transcription failed: ' . $e->getMessage());
+ foreach ($this->getProviders() as $provider) {
+ try {
+ return $provider->transcribeFile($file);
+ } catch (\Throwable $e) {
+ $this->logger->info('SpeechToText transcription using provider ' . $provider->getName() . ' failed', ['exception' => $e]);
+ }
}
+
+ throw new RuntimeException('Could not transcribe file');
}
}