-
Notifications
You must be signed in to change notification settings - Fork 509
Add support for live transcriptions in calls #15696
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
Merged
nickvergessen
merged 13 commits into
main
from
add-support-for-live-transcriptions-in-calls
Aug 29, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2ce8e7d
feat: Add capability for live transcriptions in calls
danxuliu 6bfe44f
feat: Add endpoint to enable and disable live transcriptions
danxuliu 9fdef06
feat: Add button to enable and disable live transcriptions
danxuliu 7fbdc36
feat: Show live transcriptions in web UI
danxuliu c6243f5
feat: Scroll smoothly to next transcript line
danxuliu 7e7e1b9
feat: Remove no longer visible transcript blocks
danxuliu ee4e17b
feat: Add property to store the live transcription language of rooms
danxuliu db15bc3
feat: Add endpoints to get and set the live transcription languages
danxuliu a8a7fa9
feat: Set live transcription language from Web UI
danxuliu a45883d
feat: Show loading spinner while enabling and disabling transcriptions
danxuliu dee1a50
feat: Set "lang" property on transcript chunks
danxuliu 2d55e81
feat: Set separator between transcript chunks from the language metadata
danxuliu 24a3df4
feat: Set text direction for the transcript from the language metadata
danxuliu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Talk\Controller; | ||
|
|
||
| use OCA\Talk\Exceptions\LiveTranscriptionAppNotEnabledException; | ||
| use OCA\Talk\Middleware\Attribute\RequireCallEnabled; | ||
| use OCA\Talk\Middleware\Attribute\RequireModeratorOrNoLobby; | ||
| use OCA\Talk\Middleware\Attribute\RequireModeratorParticipant; | ||
| use OCA\Talk\Middleware\Attribute\RequireParticipant; | ||
| use OCA\Talk\Participant; | ||
| use OCA\Talk\ResponseDefinitions; | ||
| use OCA\Talk\Service\LiveTranscriptionService; | ||
| use OCP\AppFramework\Http; | ||
| use OCP\AppFramework\Http\Attribute\ApiRoute; | ||
| use OCP\AppFramework\Http\Attribute\PublicPage; | ||
| use OCP\AppFramework\Http\DataResponse; | ||
| use OCP\IRequest; | ||
|
|
||
| /** | ||
| * @psalm-import-type TalkLiveTranscriptionLanguage from ResponseDefinitions | ||
| */ | ||
| class LiveTranscriptionController extends AEnvironmentAwareOCSController { | ||
| public function __construct( | ||
| string $appName, | ||
| IRequest $request, | ||
| private LiveTranscriptionService $liveTranscriptionService, | ||
| ) { | ||
| parent::__construct($appName, $request); | ||
| } | ||
|
|
||
| /** | ||
| * Enable the live transcription | ||
| * | ||
| * @return DataResponse<Http::STATUS_OK, null, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'app'|'in-call'}, array{}> | ||
| * | ||
| * 200: Live transcription enabled successfully | ||
| * 400: The external app "live_transcription" is not available | ||
| * 400: The participant is not in the call | ||
| */ | ||
| #[PublicPage] | ||
| #[RequireCallEnabled] | ||
| #[RequireModeratorOrNoLobby] | ||
| #[RequireParticipant] | ||
| #[ApiRoute(verb: 'POST', url: '/api/{apiVersion}/live-transcription/{token}', requirements: [ | ||
| 'apiVersion' => '(v1)', | ||
| 'token' => '[a-z0-9]{4,30}', | ||
| ])] | ||
| public function enable(): DataResponse { | ||
| if ($this->room->getCallFlag() === Participant::FLAG_DISCONNECTED) { | ||
| return new DataResponse(['error' => 'in-call'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
|
|
||
| if ($this->participant->getSession() && $this->participant->getSession()->getInCall() === Participant::FLAG_DISCONNECTED) { | ||
| return new DataResponse(['error' => 'in-call'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
|
|
||
| try { | ||
| $this->liveTranscriptionService->enable($this->room, $this->participant); | ||
| } catch (LiveTranscriptionAppNotEnabledException $e) { | ||
| return new DataResponse(['error' => 'app'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
|
|
||
| return new DataResponse(null); | ||
| } | ||
|
|
||
| /** | ||
| * Disable the live transcription | ||
| * | ||
| * @return DataResponse<Http::STATUS_OK, null, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'app'|'in-call'}, array{}> | ||
| * | ||
| * 200: Live transcription stopped successfully | ||
| * 400: The external app "live_transcription" is not available | ||
| * 400: The participant is not in the call | ||
| */ | ||
| #[PublicPage] | ||
| #[RequireModeratorOrNoLobby] | ||
| #[RequireParticipant] | ||
| #[ApiRoute(verb: 'DELETE', url: '/api/{apiVersion}/live-transcription/{token}', requirements: [ | ||
| 'apiVersion' => '(v1)', | ||
| 'token' => '[a-z0-9]{4,30}', | ||
| ])] | ||
| public function disable(): DataResponse { | ||
| if ($this->room->getCallFlag() === Participant::FLAG_DISCONNECTED) { | ||
| return new DataResponse(['error' => 'in-call'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
|
|
||
| if ($this->participant->getSession() && $this->participant->getSession()->getInCall() === Participant::FLAG_DISCONNECTED) { | ||
| return new DataResponse(['error' => 'in-call'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
|
|
||
| try { | ||
| $this->liveTranscriptionService->disable($this->room, $this->participant); | ||
| } catch (LiveTranscriptionAppNotEnabledException $e) { | ||
| return new DataResponse(['error' => 'app'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
|
|
||
| return new DataResponse(null); | ||
| } | ||
|
|
||
| /** | ||
| * Get available languages for live transcriptions | ||
| * | ||
| * @return DataResponse<Http::STATUS_OK, array<string, TalkLiveTranscriptionLanguage>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'app'}, array{}> | ||
| * | ||
| * 200: Available languages got successfully | ||
| * 400: The external app "live_transcription" is not available | ||
| */ | ||
| #[PublicPage] | ||
| #[ApiRoute(verb: 'GET', url: '/api/{apiVersion}/live-transcription/languages', requirements: [ | ||
| 'apiVersion' => '(v1)', | ||
| ])] | ||
| public function getAvailableLanguages(): DataResponse { | ||
| try { | ||
| $languages = $this->liveTranscriptionService->getAvailableLanguages(); | ||
| } catch (LiveTranscriptionAppNotEnabledException $e) { | ||
| return new DataResponse(['error' => 'app'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
|
|
||
| return new DataResponse($languages); | ||
| } | ||
|
|
||
| /** | ||
| * Set language for live transcriptions | ||
| * | ||
| * @param string $languageId the ID of the language to set | ||
| * @return DataResponse<Http::STATUS_OK, null, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN, array{error: 'app'}, array{}> | ||
| * | ||
| * 200: Language set successfully | ||
| * 400: The external app "live_transcription" is not available | ||
| * 403: Participant is not a moderator | ||
| */ | ||
| #[PublicPage] | ||
| #[RequireModeratorParticipant] | ||
| #[ApiRoute(verb: 'POST', url: '/api/{apiVersion}/live-transcription/{token}/language', requirements: [ | ||
| 'apiVersion' => '(v1)', | ||
| 'token' => '[a-z0-9]{4,30}', | ||
| ])] | ||
| public function setLanguage(string $languageId): DataResponse { | ||
| try { | ||
| $this->liveTranscriptionService->setLanguage($this->room, $languageId); | ||
| } catch (LiveTranscriptionAppNotEnabledException $e) { | ||
| return new DataResponse(['error' => 'app'], Http::STATUS_BAD_REQUEST); | ||
| } | ||
|
|
||
| return new DataResponse(null); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Talk\Exceptions; | ||
|
|
||
| class LiveTranscriptionAppAPIException extends \Exception { | ||
| } |
12 changes: 12 additions & 0 deletions
12
lib/Exceptions/LiveTranscriptionAppNotEnabledException.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Talk\Exceptions; | ||
|
|
||
| class LiveTranscriptionAppNotEnabledException extends \Exception { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Talk\Exceptions; | ||
|
|
||
| use OCP\Http\Client\IResponse; | ||
|
|
||
| class LiveTranscriptionAppResponseException extends \Exception { | ||
|
|
||
| public function __construct( | ||
| string $message = '', | ||
| int $code = 0, | ||
| ?\Throwable $previous = null, | ||
| protected IResponse $response, | ||
| ) { | ||
| parent::__construct($message, $code, $previous); | ||
| } | ||
|
|
||
| public function getResponse(): IResponse { | ||
| return $this->response; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Talk\Migration; | ||
|
|
||
| use Closure; | ||
| use OCP\DB\ISchemaWrapper; | ||
| use OCP\DB\Types; | ||
| use OCP\Migration\IOutput; | ||
| use OCP\Migration\SimpleMigrationStep; | ||
|
|
||
| class Version22000Date20250813122342 extends SimpleMigrationStep { | ||
|
|
||
| /** | ||
| * @param IOutput $output | ||
| * @param Closure(): ISchemaWrapper $schemaClosure | ||
| * @param array $options | ||
| * @return null|ISchemaWrapper | ||
| */ | ||
| #[\Override] | ||
| public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { | ||
| /** @var ISchemaWrapper $schema */ | ||
| $schema = $schemaClosure(); | ||
|
|
||
| $table = $schema->getTable('talk_rooms'); | ||
| if (!$table->hasColumn('transcription_language')) { | ||
| $table->addColumn('transcription_language', Types::STRING, [ | ||
| 'notnull' => false, | ||
| 'default' => '', | ||
| 'length' => 16, | ||
| ]); | ||
| } | ||
|
|
||
| return $schema; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.