mirror of
https://github.com/suitenumerique/meet.git
synced 2026-09-03 22:25:27 +00:00
✨(backend) add start-subtitle endpoint
Allow any user, anonymous or authenticated, to start subtitling in a room only if they are an active participant of it. Subtitling a room consists of starting the multi-user transcriber agent. This agent forwards all participants' audio to an STT server and returns transcription segments for any active voice to the room. User roles in the backend room system cannot be used to determine subtitle permissions. The transcriber agent can be triggered multiple times but will only join a room once. Unicity is managed by the agent itself. Any user with a valid LiveKit token can initiate subtitles. Feature flag logic is implemented on the frontend. The frontend ensures the "start subtitle" action is only available to users who should see it. The backend does not enforce feature flags in this version. Authentication in our system does not imply access to a room. The only valid proof of access is the LiveKit API token issued by the backend. Security consideration: A LiveKit API token is valid for 6 hours and cannot be revoked at the end of a meeting. It is important to verify that the token was issued for the correct room. Calls to the agent dispatch endpoint must be server-initiated. The backend proxies these calls, as clients cannot securely contact the agent dispatch endpoint directly (per LiveKit documentation). Room ID is passed as a query parameter. There is currently no validation ensuring that the room exists prior to agent dispatch. TODO: implement validation or error handling for non-existent rooms. The backend does not forward LiveKit tokens to the agent. Default API rate limiting is applied to prevent abuse.
This commit is contained in:
committed by
aleb_the_flash
parent
49ee46438b
commit
f48dd5cea1
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
Test subtitle service.
|
||||
"""
|
||||
|
||||
# pylint: disable=W0621
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from core.factories import RoomFactory
|
||||
from core.services.subtitle import SubtitleService
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_livekit_client():
|
||||
"""Mock LiveKit API client."""
|
||||
with mock.patch("core.utils.create_livekit_client") as mock_create:
|
||||
mock_client = mock.AsyncMock()
|
||||
mock_create.return_value = mock_client
|
||||
yield mock_client
|
||||
|
||||
|
||||
def test_start_subtitle_settings(mock_livekit_client, settings):
|
||||
"""Test that start_subtitle uses the configured agent name from Django settings."""
|
||||
|
||||
settings.ROOM_SUBTITLE_AGENT_NAME = "fake-subtitle-agent-name"
|
||||
|
||||
room = RoomFactory(name="my room")
|
||||
SubtitleService().start_subtitle(room)
|
||||
|
||||
mock_livekit_client.agent_dispatch.create_dispatch.assert_called_once()
|
||||
|
||||
call_args = mock_livekit_client.agent_dispatch.create_dispatch.call_args[0][0]
|
||||
assert call_args.agent_name == "fake-subtitle-agent-name"
|
||||
assert call_args.room == str(room.id)
|
||||
|
||||
|
||||
def test_stop_subtitle_not_implemented():
|
||||
"""Test that stop_subtitle raises NotImplementedError."""
|
||||
|
||||
room = RoomFactory(name="my room")
|
||||
|
||||
with pytest.raises(
|
||||
NotImplementedError, match="Subtitle agent stopping not yet implemented"
|
||||
):
|
||||
SubtitleService().stop_subtitle(room)
|
||||
Reference in New Issue
Block a user