Pass Websocket to the context if available (#329)

* Add code

* Code

* Fix

* Add code
This commit is contained in:
Freddy Boulton
2025-05-30 13:38:59 -04:00
committed by GitHub
parent 3fc258cd1b
commit 0c146ee45e
2 changed files with 20 additions and 14 deletions

View File

@@ -16,6 +16,7 @@ from typing import Any, Literal, Protocol, TypedDict, cast
import av
import librosa
import numpy as np
from fastapi import WebSocket
from numpy.typing import NDArray
from pydub import AudioSegment
@@ -67,6 +68,7 @@ current_channel: ContextVar[DataChannel | None] = ContextVar(
@dataclass
class Context:
webrtc_id: str
websocket: WebSocket | None = None
current_context: ContextVar[Context | None] = ContextVar(