It seems calling a Python function is somewhat limited. According to the docs, anvil.call can only be used on a Custom HTML form. If we have any other type of form, we can’t use that JavaScript function.
I couldn’t find anything in the docs about using anvil.server.call. When I tried to use it, I got TypeError: Cannot read properties of undefined (reading 'call')
I am not sure how else I can capture microphone audio from a device, and use it within my app, because as far as I know, we can only do this with JavaScript’s getUserMedia() function.
You can use anvil.js to call JavaScript from within client-side Python. That’s what this solution is using, I think:
p.s.
I’m not understanding how this limits anything. If you want to use that JavaScript on a form, use a Custom HTML form. (Any form can be changed to “Custom HTML” by selecting the ‘html’ dropdown under ‘properties’. If you want it to have the same html as the standard form, just copy the html from standard_page.html into the Custom HTML for that form.)