Delete pages/4_delayed_echo.py
Browse files- pages/4_delayed_echo.py +0 -43
pages/4_delayed_echo.py
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
import asyncio
|
2 |
-
import logging
|
3 |
-
from typing import List
|
4 |
-
|
5 |
-
import av
|
6 |
-
import streamlit as st
|
7 |
-
from streamlit_webrtc import WebRtcMode, webrtc_streamer
|
8 |
-
|
9 |
-
from sample_utils.turn import get_ice_servers
|
10 |
-
|
11 |
-
logger = logging.getLogger(__name__)
|
12 |
-
|
13 |
-
|
14 |
-
delay = st.slider("Delay", 0.0, 5.0, 1.0, 0.05)
|
15 |
-
|
16 |
-
|
17 |
-
async def queued_video_frames_callback(
|
18 |
-
frames: List[av.VideoFrame],
|
19 |
-
) -> List[av.VideoFrame]:
|
20 |
-
logger.debug("Delay: %f", delay)
|
21 |
-
# A standalone `await ...` is interpreted as an expression and
|
22 |
-
# the Streamlit magic's target, which leads implicit calls of `st.write`.
|
23 |
-
# To prevent it, fix it as `_ = await ...`, a statement.
|
24 |
-
# See https://discuss.streamlit.io/t/issue-with-asyncio-run-in-streamlit/7745/15
|
25 |
-
await asyncio.sleep(delay)
|
26 |
-
return frames
|
27 |
-
|
28 |
-
|
29 |
-
async def queued_audio_frames_callback(
|
30 |
-
frames: List[av.AudioFrame],
|
31 |
-
) -> List[av.AudioFrame]:
|
32 |
-
await asyncio.sleep(delay)
|
33 |
-
return frames
|
34 |
-
|
35 |
-
|
36 |
-
webrtc_streamer(
|
37 |
-
key="delay",
|
38 |
-
mode=WebRtcMode.SENDRECV,
|
39 |
-
rtc_configuration={"iceServers": get_ice_servers()},
|
40 |
-
queued_video_frames_callback=queued_video_frames_callback,
|
41 |
-
queued_audio_frames_callback=queued_audio_frames_callback,
|
42 |
-
async_processing=True,
|
43 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|