streamlit-webrtc 0.62.4__tar.gz → 0.63.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/PKG-INFO +2 -2
  2. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/pyproject.toml +1 -1
  3. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/__init__.py +15 -2
  4. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/factory.py +35 -1
  5. streamlit_webrtc-0.62.4/streamlit_webrtc/frontend/dist/assets/index-DWHlEvv5.js → streamlit_webrtc-0.63.1/streamlit_webrtc/frontend/dist/assets/index-Cn4hJFys.js +20 -20
  6. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/frontend/dist/index.html +1 -1
  7. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/source.py +61 -0
  8. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/.gitignore +0 -0
  9. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/LICENSE +0 -0
  10. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/README.md +0 -0
  11. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/_compat.py +0 -0
  12. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/component.py +0 -0
  13. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/components_callbacks.py +0 -0
  14. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/config.py +0 -0
  15. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/credentials.py +0 -0
  16. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/eventloop.py +0 -0
  17. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/mix.py +0 -0
  18. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/models.py +0 -0
  19. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/process.py +0 -0
  20. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/py.typed +0 -0
  21. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/receive.py +0 -0
  22. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/relay.py +0 -0
  23. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/server.py +0 -0
  24. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/session_info.py +0 -0
  25. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/shutdown.py +0 -0
  26. {streamlit_webrtc-0.62.4 → streamlit_webrtc-0.63.1}/streamlit_webrtc/webrtc.py +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-webrtc
3
- Version: 0.62.4
3
+ Version: 0.63.1
4
4
  Summary: Real-time video and audio processing on Streamlit
5
5
  Project-URL: Repository, https://github.com/whitphx/streamlit-webrtc
6
6
  Author-email: "Yuichiro Tachibana (Tsuchiya)" <t.yic.yt@gmail.com>
7
7
  License-Expression: MIT
8
8
  License-File: LICENSE
9
9
  Requires-Python: !=3.9.7,>=3.9
10
- Requires-Dist: aioice>=0.10.0
10
+ Requires-Dist: aioice>=0.10.1
11
11
  Requires-Dist: aiortc>=1.11.0
12
12
  Requires-Dist: packaging>=20.0
13
13
  Requires-Dist: streamlit>=0.89.0
@@ -13,7 +13,7 @@ dependencies = [
13
13
  "streamlit>=0.89.0",
14
14
  "aiortc>=1.11.0", # aiortc<1.4.0 causes an error with cryptography>=39.0.0. See https://github.com/whitphx/streamlit-webrtc/issues/1164. The fix was introduced into aiortc in https://github.com/aiortc/aiortc/commit/08b0a7e9f5030a9f7e5617382e92560d4ae763a2 that 1.4.0 included.
15
15
  "packaging>=20.0",
16
- "aioice>=0.10.0",
16
+ "aioice>=0.10.1",
17
17
  ]
18
18
 
19
19
  [project.urls]
@@ -21,9 +21,19 @@ from .credentials import (
21
21
  get_hf_ice_servers,
22
22
  get_twilio_ice_servers,
23
23
  )
24
- from .factory import create_mix_track, create_process_track, create_video_source_track
24
+ from .factory import (
25
+ create_audio_source_track,
26
+ create_mix_track,
27
+ create_process_track,
28
+ create_video_source_track,
29
+ )
25
30
  from .mix import MediaStreamMixTrack, MixerCallback
26
- from .source import VideoSourceCallback, VideoSourceTrack
31
+ from .source import (
32
+ AudioSourceCallback,
33
+ AudioSourceTrack,
34
+ VideoSourceCallback,
35
+ VideoSourceTrack,
36
+ )
27
37
  from .webrtc import (
28
38
  AudioProcessorBase,
29
39
  AudioProcessorFactory,
@@ -64,7 +74,10 @@ __all__ = [
64
74
  "VideoReceiver",
65
75
  "VideoSourceTrack",
66
76
  "VideoSourceCallback",
77
+ "AudioSourceTrack",
78
+ "AudioSourceCallback",
67
79
  "create_video_source_track",
80
+ "create_audio_source_track",
68
81
  "WebRtcMode",
69
82
  "WebRtcWorker",
70
83
  "MediaStreamConstraints",
@@ -25,7 +25,12 @@ from .process import (
25
25
  VideoProcessTrack,
26
26
  )
27
27
  from .relay import get_global_relay
28
- from .source import VideoSourceCallback, VideoSourceTrack
28
+ from .source import (
29
+ AudioSourceCallback,
30
+ AudioSourceTrack,
31
+ VideoSourceCallback,
32
+ VideoSourceTrack,
33
+ )
29
34
 
30
35
  _PROCESSOR_TRACK_CACHE_KEY_PREFIX = "__PROCESSOR_TRACK_CACHE__"
31
36
 
@@ -204,3 +209,32 @@ def create_video_source_track(
204
209
  video_source_track = VideoSourceTrack(callback=callback, fps=fps)
205
210
  st.session_state[cache_key] = video_source_track
206
211
  return video_source_track
212
+
213
+
214
+ _AUDIO_SOURCE_TRACK_CACHE_KEY_PREFIX = "__AUDIO_SOURCE_TRACK_CACHE__"
215
+
216
+
217
+ def create_audio_source_track(
218
+ callback: AudioSourceCallback,
219
+ key: str,
220
+ sample_rate: int = 48000,
221
+ ptime: float = 0.020,
222
+ ) -> AudioSourceTrack:
223
+ cache_key = _AUDIO_SOURCE_TRACK_CACHE_KEY_PREFIX + key
224
+ if (
225
+ cache_key in st.session_state
226
+ and isinstance(st.session_state[cache_key], AudioSourceTrack)
227
+ and st.session_state[cache_key].kind == "audio"
228
+ and st.session_state[cache_key].readyState == "live"
229
+ ):
230
+ audio_source_track: AudioSourceTrack = st.session_state[cache_key]
231
+ audio_source_track._callback = callback
232
+ audio_source_track._sample_rate = sample_rate
233
+ audio_source_track._ptime = ptime
234
+ audio_source_track._samples_per_frame = int(sample_rate * ptime)
235
+ else:
236
+ audio_source_track = AudioSourceTrack(
237
+ callback=callback, sample_rate=sample_rate, ptime=ptime
238
+ )
239
+ st.session_state[cache_key] = audio_source_track
240
+ return audio_source_track