Skip to content
Discussion options

You must be logged in to vote

Here is a proof-of-concept for recording audio with NiceGUI. It records 3 seconds and plays it back afterwards:

async def record():
    await ui.run_javascript('''
        navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
            const mediaRecorder = new MediaRecorder(stream);
            mediaRecorder.start();

            const audioChunks = [];
            mediaRecorder.addEventListener("dataavailable", event => audioChunks.push(event.data));

            mediaRecorder.addEventListener("stop", () => {
                const audioBlob = new Blob(audioChunks);
                const audioUrl = URL.createObjectURL(audioBlob);
                const audio = new Audio(…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@coolmian
Comment options

Answer selected by coolmian
Comment options

You must be logged in to vote
3 replies
@falkoschindler
Comment options

@programus
Comment options

@rodja
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #568 on March 20, 2023 08:37.