Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(call): Add warning to AI summary and transcript #13825

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading