Code Monkey home page Code Monkey logo

streamlit-webrtc-example's Introduction

title emoji colorFrom colorTo sdk sdk_version app_file pinned license
Streamlit Webrtc Example
๐ŸŒ
purple
yellow
streamlit
1.26.0
app.py
false
mit

streamlit-webrtc-example

Hosted on Streamlit Cloud: Open in Streamlit https://webrtc.streamlit.app/

ko-fi

Buy Me A Coffee

GitHub Sponsors

Deployment notes

Streamlit Cloud automatically triggers the deployment on its CI/CD.

streamlit-webrtc-example's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar whitphx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

streamlit-webrtc-example's Issues

How to listen on_audio_ended event

Hi,
Thanks for this wonderful toolkit,I tried to listen the on_audio_ended event, I can not find your example, but my listener is not working,
so could you help me and add it to your examples?

Bug

Hi @whitphx ,The streamlet link that you have provide in about section is not working it is showing error please solve it

Camera is not opening when clicking Start button

Hello,
I was just testing the suggested demo app after the new version release and encountered the following behavior:
First, on the start button it starts loading...
Capture1

Then, after a while (20sec approx.) it changes to the following screen...
Capture2

After that the camera does not open and returns to the initial state.

swscaler warning

I am trying to grab a stream from IP camera through RTSP.

for every frame I get [swscaler @ 0x7b4d844f10] deprecated pixel format used, make sure you did set range correctly printed in the console

FFMPEG Details:

ffmpeg version 3.4.11-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil      55. 78.100 / 55. 78.100
libavcodec     57.107.100 / 57.107.100
libavformat    57. 83.100 / 57. 83.100
libavdevice    57. 10.100 / 57. 10.100
libavfilter     6.107.100 /  6.107.100
libavresample   3.  7.  0 /  3.  7.  0
libswscale      4.  8.100 /  4.  8.100
libswresample   2.  9.100 /  2.  9.100
libpostproc    54.  7.100 / 54.  7.100

Other Details

  1. python 3.9.14
  2. streamlit 1.11.0
  3. streamlit_webrtc version: 0.43.4

Examples do not work

Good day, could you please check if everything is fine with the examples page, nothing seem to work right now. Tried on different browsers and devices.

How do i export the recorded audio into a separate file ?

`
complete_audio_chunk = pydub.AudioSegment.empty()
while True:
if webrtc_ctx.audio_receiver:
sound_chunk = pydub.AudioSegment.empty()
try:
audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=1)
except queue.Empty:
time.sleep(0.1)
status_indicator.write("No frame arrived.")
continue

        status_indicator.write("Running. Say something!")
        for idx, audio_frame in enumerate(audio_frames):
            sound = pydub.AudioSegment(
                data=audio_frame.to_ndarray().tobytes(),
                sample_width=audio_frame.format.bytes,
                frame_rate=audio_frame.sample_rate,
                channels=len(audio_frame.layout.channels),
            )
            op = str(idx) + "omg" + str(audio_frame.to_ndarray().shape)
            text_output.write(op)
            sound_chunk += sound
            complete_audio_chunk += sound
    else:
        status_indicator.write("Audio Receiver is not set. Abort.")
        break

    complete_audio_chunk.export("/home/kp/temp/audio_file.wav", format="wav")
    logger.info("ENEDNEND call")
    st.write("end call")

`

I tried the above code, (copied from https://github.com/whitphx/streamlit-webrtc-example/blob/main/app.py). Only audio frames are of interest for me. But, audio is not saved in audio_file.wav at all.

How to remotely record?

Hi,
Thanks for this wonderful toolkit, I tried to set up this demo on the server but always failed.
If I run the example locally, everything works perfectly (accessed by localhost:port), but if I want to use it remotely, say, deploying it on a server and accessing it using the IP:port, it doesn't work anymore. BTW, the demo page on hosted on the streamlit server you presented also failed for me. I would like to ask, do I need any extra setups? (I have already allowed the related permissions and the pop-up to allow the microphone can successfully be launched)
Thanks a lot!
Shuai

streamlit-webrct doesn't work with faster-whisper model

Hi, i'm working on voice translator app, and trying streamlit-webrtc with faster-whisper model
I noticed this link :https://github.com/whitphx/streamlit-webrtc/blob/main/pages/10_sendonly_audio.py
and found there is a while loop to handle audio data like below:

while True:
    if webrtc_ctx.audio_receiver:
        try:
            audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=1)
        except queue.Empty:
            logger.warning("Queue is empty. Abort.")
            break

        sound_chunk = pydub.AudioSegment.empty()
        for audio_frame in audio_frames:
            sound = pydub.AudioSegment(
                data=audio_frame.to_ndarray().tobytes(),
                sample_width=audio_frame.format.bytes,
                frame_rate=audio_frame.sample_rate,
                channels=len(audio_frame.layout.channels),
...


Doesn't it block UI thread since the while loop is in UI thread in my point view, and once i use below code, the page is pending.
Below is my code, please help to figure out how to fix it

webrtc_ctx = webrtc_streamer(
    key="speech-to-text",
    mode=WebRtcMode.SENDONLY,
    audio_receiver_size=10240,
    rtc_configuration={"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]},
    media_stream_constraints={"video": False, "audio": True},
)

status_indicator = st.empty()
text_output = st.empty()
stream = None

while True:
    if webrtc_ctx.audio_receiver:
        sound_chunk = pydub.AudioSegment.empty()
        try:
            audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=1)
        except queue.Empty:
            time.sleep(0.1)
            status_indicator.write("No frame arrived.")

        status_indicator.write("Running. Say something!")

        for audio_frame in audio_frames:
            sound = pydub.AudioSegment(
                data=audio_frame.to_ndarray().tobytes(),
                sample_width=audio_frame.format.bytes,
                frame_rate=audio_frame.sample_rate,
                channels=len(audio_frame.layout.channels),
            )
            sound_chunk += sound
        print(sound_chunk)
        if len(sound_chunk) > 0:
            sound_chunk = sound_chunk.set_channels(1).set_frame_rate(44100)
            buffer = np.array(sound_chunk.get_array_of_samples())

            segments, _ = WhisperModel(model_size
                                       , device=f"{'cuda' if supports_gpu else 'cpu'}"
                                       , compute_type=compute_type).transcribe(buffer)
            transcript = " ".join(segment.text for segment in segments)
            print(transcript)
            text = " ".join(segment.text for segment in segments)
            text_output.markdown(f"**Text:** {text}")
    else:
        status_indicator.write("AudioReciver is not set. Abort.")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.