move setting of userId before provider execution

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
This commit is contained in:
Andrey Borysenko 2024-01-14 20:44:43 +02:00
parent 13588c7566
commit ea7f1f9ecd
No known key found for this signature in database
GPG key ID: 934CB29F9F59B0D1

View file

@ -126,9 +126,6 @@ class SpeechToTextManager implements ISpeechToTextManager {
if ($provider instanceof ISpeechToTextProviderWithId) {
return $provider->getId() === $classNameOrId;
}
if ($provider instanceof ISpeechToTextProviderWithUserId) {
$provider->setUserId($this->userSession->getUser()?->getUID());
}
return $provider::class === $classNameOrId;
}));
if ($provider !== false) {
@ -138,6 +135,9 @@ class SpeechToTextManager implements ISpeechToTextManager {
foreach ($providers as $provider) {
try {
if ($provider instanceof ISpeechToTextProviderWithUserId) {
$provider->setUserId($this->userSession->getUser()?->getUID());
}
return $provider->transcribeFile($file);
} catch (\Throwable $e) {
$this->logger->info('SpeechToText transcription using provider ' . $provider->getName() . ' failed', ['exception' => $e]);