diff --git a/lib/Service/RecordingService.php b/lib/Service/RecordingService.php index 448e31e01da..c3bb3d5122d 100644 --- a/lib/Service/RecordingService.php +++ b/lib/Service/RecordingService.php @@ -28,6 +28,8 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\IConfig; +use OCP\IUserManager; +use OCP\L10N\IFactory; use OCP\Notification\IManager; use OCP\Share\IManager as ShareManager; use OCP\Share\IShare; @@ -77,6 +79,8 @@ public function __construct( protected LoggerInterface $logger, protected BackendNotifier $backendNotifier, protected ITaskProcessingManager $taskProcessingManager, + protected IFactory $l10nFactory, + protected IUserManager $userManager, ) { } @@ -143,7 +147,7 @@ public function store(Room $room, string $owner, array $file): void { } $shouldTranscribe = $this->serverConfig->getAppValue('spreed', 'call_recording_transcription', 'no') === 'yes'; - $shouldSummarize = $this->serverConfig->getAppValue('spreed', 'call_recording_summary', 'no') === 'yes'; + $shouldSummarize = $this->serverConfig->getAppValue('spreed', 'call_recording_summary', 'yes') === 'yes'; if (!$shouldTranscribe && !$shouldSummarize) { $this->logger->debug('Skipping transcription and summary of call recording, as both are disabled'); return; @@ -203,7 +207,7 @@ public function storeTranscript(string $owner, string $roomToken, int $recording } $shouldTranscribe = $this->serverConfig->getAppValue('spreed', 'call_recording_transcription', 'no') === 'yes'; - $shouldSummarize = $this->serverConfig->getAppValue('spreed', 'call_recording_summary', 'no') === 'yes'; + $shouldSummarize = $this->serverConfig->getAppValue('spreed', 'call_recording_summary', 'yes') === 'yes'; if ($aiTask === 'transcript') { $transcriptFileName = pathinfo($recording->getName(), PATHINFO_FILENAME) . '.md'; @@ -216,8 +220,21 @@ public function storeTranscript(string $owner, string $roomToken, int $recording if (($shouldTranscribe && $aiTask === 'transcript') || ($shouldSummarize && $aiTask === 'summary')) { + $user = $this->userManager->get($owner); + $language = $this->l10nFactory->getUserLanguage($user); + $l = $this->l10nFactory->get(Application::APP_ID, $language); + + if ($aiTask === 'transcript') { + $warning = $l->t('Transcript is AI generated and may contain mistakes'); + } else { + $warning = $l->t('Summary is AI generated and may contain mistakes'); + } + try { - $fileNode = $recordingFolder->newFile($transcriptFileName, $output); + $fileNode = $recordingFolder->newFile( + $transcriptFileName, + $output . "\n\n$warning\n", + ); $this->notifyStoredTranscript($room, $participant, $fileNode, $aiTask); } catch (NoUserException) { throw new InvalidArgumentException('owner_invalid'); diff --git a/tests/php/Service/RecordingServiceTest.php b/tests/php/Service/RecordingServiceTest.php index 1503a0ac2fa..8a41cbd15e9 100644 --- a/tests/php/Service/RecordingServiceTest.php +++ b/tests/php/Service/RecordingServiceTest.php @@ -33,6 +33,8 @@ function is_uploaded_file($filename) { use OCP\Files\IMimeTypeDetector; use OCP\Files\IRootFolder; use OCP\IConfig; +use OCP\IUserManager; +use OCP\L10N\IFactory; use OCP\Notification\IManager; use OCP\Share\IManager as ShareManager; use OCP\TaskProcessing\IManager as ITaskProcessingManager; @@ -56,6 +58,8 @@ class RecordingServiceTest extends TestCase { protected LoggerInterface&MockObject $logger; protected BackendNotifier&MockObject $backendNotifier; protected ITaskProcessingManager&MockObject $taskProcessingManager; + protected IFactory&MockObject $l10nFactory; + protected IUserManager&MockObject $userManager; protected RecordingService $recordingService; public function setUp(): void { @@ -76,6 +80,8 @@ public function setUp(): void { $this->logger = $this->createMock(LoggerInterface::class); $this->backendNotifier = $this->createMock(BackendNotifier::class); $this->taskProcessingManager = $this->createMock(ITaskProcessingManager::class); + $this->l10nFactory = $this->createMock(IFactory::class); + $this->userManager = $this->createMock(IUserManager::class); $this->recordingService = new RecordingService( $this->mimeTypeDetector, @@ -93,6 +99,8 @@ public function setUp(): void { $this->logger, $this->backendNotifier, $this->taskProcessingManager, + $this->l10nFactory, + $this->userManager, ); }