Skip to content
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

Audio recorder is slow when initialization #283

Closed
garymmi opened this issue Jul 1, 2021 · 10 comments
Closed

Audio recorder is slow when initialization #283

garymmi opened this issue Jul 1, 2021 · 10 comments

Comments

@garymmi
Copy link

garymmi commented Jul 1, 2021

I run the example :
WebRTC is sendonly and audio frames are visualized with matplotlib (sendonly)
when I pressed the Start button , record device seems to initialize for a long time
image
after around 40 seconds, then show the graph
image

below is log message
~$ streamlit run https://github.com/raw/whitphx/streamlit-webrtc-example/main/app.py

You can now view your Streamlit app in your browser.

Network URL: http://172.28.53.133:8501
External URL: http://114.32.244.17:8501

[2021-07-01 15:39:10,548] WARNING from main in /tmp/tmpvsih9xwf/app.py:672: AudioReciver is not set. Abort.
[2021-07-01 15:39:54,641] DEBUG from streamlit_webrtc in /home/gary/work/mypy3/lib/python3.8/site-packages/streamlit_webrtc/init.py:311: No worker exists though the offer SDP is set. Create a new worker (key="sendonly-audio").
[2021-07-01 15:39:54,657] DEBUG from streamlit_webrtc.webrtc in /home/gary/work/mypy3/lib/python3.8/site-packages/streamlit_webrtc/webrtc.py:381: _webrtc_thread_impl starts
[2021-07-01 15:39:54,662] INFO from streamlit_webrtc.webrtc in /home/gary/work/mypy3/lib/python3.8/site-packages/streamlit_webrtc/webrtc.py:176: Track audio received
[2021-07-01 15:39:54,662] INFO from streamlit_webrtc.webrtc in /home/gary/work/mypy3/lib/python3.8/site-packages/streamlit_webrtc/webrtc.py:180: Add a track <aiortc.rtcrtpreceiver.RemoteStreamTrack object at 0x7fcc958864f0> to receiver <streamlit_webrtc.receive.MediaReceiver object at 0x7fcc95866c70>
[2021-07-01 15:39:54,662] INFO from streamlit_webrtc.webrtc in /home/gary/work/mypy3/lib/python3.8/site-packages/streamlit_webrtc/webrtc.py:176: Track video received
[2021-07-01 15:39:54,662] INFO from streamlit_webrtc.webrtc in /home/gary/work/mypy3/lib/python3.8/site-packages/streamlit_webrtc/webrtc.py:186: Add a track <aiortc.rtcrtpreceiver.RemoteStreamTrack object at 0x7fcc95835f40> to receiver <streamlit_webrtc.receive.MediaReceiver object at 0x7fcc95866a90>
[2021-07-01 15:39:54,675] INFO from aioice.ice in /home/gary/work/mypy3/lib/python3.8/site-packages/aioice/ice.py:1061: Connection(0) Check CandidatePair(('172.28.53.133', 52580) -> ('172.28.48.1', 59954)) State.FROZEN -> State.WAITING
[2021-07-01 15:39:54,675] INFO from aioice.ice in /home/gary/work/mypy3/lib/python3.8/site-packages/aioice/ice.py:1061: Connection(0) Check CandidatePair(('172.28.53.133', 52580) -> ('10.0.0.3', 59955)) State.FROZEN -> State.WAITING
[2021-07-01 15:39:54,718] INFO from streamlit_webrtc.webrtc in /home/gary/work/mypy3/lib/python3.8/site-packages/streamlit_webrtc/webrtc.py:91: ICE connection state is checking
[2021-07-01 15:39:54,990] INFO from aioice.ice in /home/gary/work/mypy3/lib/python3.8/site-packages/aioice/ice.py:1061: Connection(0) Check CandidatePair(('172.28.53.133', 52580) -> ('172.28.48.1', 59954)) State.WAITING -> State.IN_PROGRESS
[2021-07-01 15:39:54,992] INFO from aioice.ice in /home/gary/work/mypy3/lib/python3.8/site-packages/aioice/ice.py:1061: Connection(0) Check CandidatePair(('172.28.53.133', 52580) -> ('10.0.0.3', 59955)) State.WAITING -> State.IN_PROGRESS
[2021-07-01 15:39:55,012] INFO from aioice.ice in /home/gary/work/mypy3/lib/python3.8/site-packages/aioice/ice.py:1061: Connection(0) Check CandidatePair(('172.28.53.133', 52580) -> ('192.168.137.1', 59956)) State.FROZEN -> State.IN_PROGRESS
[2021-07-01 15:39:55,033] INFO from aioice.ice in /home/gary/work/mypy3/lib/python3.8/site-packages/aioice/ice.py:1061: Connection(0) Check CandidatePair(('172.28.53.133', 52580) -> ('114.32.244.17', 59955)) State.FROZEN -> State.IN_PROGRESS
[2021-07-01 15:39:55,493] INFO from aioice.ice in /home/gary/work/mypy3/lib/python3.8/site-packages/aioice/ice.py:1061: Connection(0) Check CandidatePair(('172.28.53.133', 52580) -> ('172.28.48.1', 59954)) State.IN_PROGRESS -> State.SUCCEEDED
[2021-07-01 15:39:55,493] INFO from aioice.ice in /home/gary/work/mypy3/lib/python3.8/site-packages/aioice/ice.py:1061: Connection(0) ICE completed
[2021-07-01 15:39:55,501] INFO from streamlit_webrtc.webrtc in /home/gary/work/mypy3/lib/python3.8/site-packages/streamlit_webrtc/webrtc.py:91: ICE connection state is completed

@whitphx
Copy link
Owner

whitphx commented Jul 2, 2021

Is it only for audio app?
Share the details of your environment like OS, the versions of Streamlit and streamlit-webrtc, etc.

@garymmi
Copy link
Author

garymmi commented Jul 3, 2021

thanks for your replay
camera example also the same
here are my environment, I use WSL
ubuntu 16.04
python 3.8.9
streamlit 0.83.0
streamlit-webrtc 0.23.3

in windows, I use chrome to see the app

I also try to install python , streamlit, streamlit-webrtc in windows
also meet the same condition

@whitphx
Copy link
Owner

whitphx commented Jul 8, 2021

mm, I can't find something wrong from that info.
Can you try running it on another environment like pure Linux or better hardware?

@garymmi
Copy link
Author

garymmi commented Jul 9, 2021

thanks for your help

I tried to use safari on ipad, it run more smoothly
press start button and wait 3 seconds, then show the graph in screen

my test url : https://share.streamlit.io/whitphx/streamlit-webrtc-example/main/app.py

@garymmi
Copy link
Author

garymmi commented Jul 9, 2021

if use firefox to test, wait around 15 seconds.

safari on ipad: 3 seconds
chrome on android: 3 seconds
chrome on win10 : 40 seconds
firefox on win10: 15 seconds

@whitphx
Copy link
Owner

whitphx commented Jul 14, 2021

Thank you for the report, but I can't find the reason and only guess it roots around the network, browser, middleware, etc...
FYI, in my environment, chrome + M1 mac mini, it takes ~2 or 3 secs.

@garymmi
Copy link
Author

garymmi commented Jul 15, 2021

another test
use chrome to test on win10 but this time use incognito window
image

it work ok , take 3 seconds

but i press stop button , and then press start button . it still wait 40 seconds, very strange

@Jackiexiao
Copy link

I encounter same issue, it take 43s, I run streamlit-webrtc-example on remnote machine(ubuntu) and visit remotehost:port on window 10 chrome (with chrome://flags/#unsafely-treat-insecure-origin-as-secure enable) @whitphx

detail log:

[2021-07-30 16:42:14,015] WARNING from __main__ in /data1/xiaojianjin/zhuiyi/tts/jutil/scripts/zhuiyi/client/testaudio.py:631: AudioReciver is not set. Abort.[2021-07-30 16:42:57,276]   DEBUG from streamlit_webrtc.component in /data1/xiaojianjin/anaconda3/lib/python3.8/site-packages/streamlit_webrtc/component.py:421: No worker exists though the offer SDP is set. Create a new worker (key="sendonly-audio").
[2021-07-30 16:42:57,305]   DEBUG from streamlit_webrtc.webrtc in /data1/xiaojianjin/anaconda3/lib/python3.8/site-packages/streamlit_webrtc/webrtc.py:426: _webrtc_thread_impl starts
[2021-07-30 16:42:57,313]    INFO from streamlit_webrtc.webrtc in /data1/xiaojianjin/anaconda3/lib/python3.8/site-packages/streamlit_webrtc/webrtc.py:203: Track audio received                                                                                                                                                                                                                           14:51:43  30-Jul-21  gpu01 [2021-07-30 16:42:57,313]    INFO from streamlit_webrtc.webrtc in /data1/xiaojianjin/anaconda3/lib/python3.8/site-packages/streamlit_webrtc/webrtc.py:212: Add a track <aiortc.rtcrtpreceiver.RemoteStreamTrack object at 0x7fd5d8ebee20> to receiver <streamlit_webrtc.receive.MediaReceiver object at 0x7fd5d8eb46d0>
[2021-07-30 16:42:57,938]    INFO from aioice.ice in /data1/xiaojianjin/anaconda3/lib/python3.8/site-packages/aioice/ice.py:1061: Connection(0) Check CandidatePair(('172.18.159.1', 42630) -> ('192.168.10.29', 63237)) State.FROZEN -> State.WAITING
[2021-07-30 16:42:57,938]    INFO from aioice.ice in /data1/xiaojianjin/anaconda3/lib/python3.8/site-packages/aioice/ice.py:1061: Connection(0) Check CandidatePair(('172.17.0.1', 36342) -> ('192.168.10.29', 63237)) State.FROZEN -> State.WAITING

@Jackiexiao
Copy link

Jackiexiao commented Jul 30, 2021

ok.... after I change stun server, it works fine... china network issue againnnnn...

    rtc_configuration={"iceServers": [{"urls": ["stun:stun.xten.com:3478"]}]},

instead of using stun:stun.l.google.com:19302

@whitphx
Copy link
Owner

whitphx commented Jul 30, 2021

Oh, I have never thought of that... nice problem solving, thanks :)

@whitphx whitphx closed this as completed Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants