Skip to content

Commit

Permalink
Merge pull request #13825 from nextcloud/bugfix/noid/add-AI-warning
Browse files Browse the repository at this point in the history
fix(call): Add warning to AI summary and transcript
  • Loading branch information
nickvergessen authored Nov 20, 2024
2 parents 68024dd + 7b94e06 commit f8fa4c9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
23 changes: 20 additions & 3 deletions lib/Service/RecordingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -77,6 +79,8 @@ public function __construct(
protected LoggerInterface $logger,
protected BackendNotifier $backendNotifier,
protected ITaskProcessingManager $taskProcessingManager,
protected IFactory $l10nFactory,
protected IUserManager $userManager,
) {
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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';
Expand All @@ -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');
Expand Down
8 changes: 8 additions & 0 deletions tests/php/Service/RecordingServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -93,6 +99,8 @@ public function setUp(): void {
$this->logger,
$this->backendNotifier,
$this->taskProcessingManager,
$this->l10nFactory,
$this->userManager,
);
}

Expand Down

0 comments on commit f8fa4c9

Please sign in to comment.