Picovoice / eagle

On-device speaker recognition engine powered by deep learning
Apache License 2.0
26 stars 2 forks source link

Eagle Issue: Failed to initialize PvRecorder when deployed as a gradio app #75

Closed LongMingWei closed 2 months ago

LongMingWei commented 2 months ago

Have you checked the docs and existing issues?

SDK

Python

Eagle package version

1.0.1

Framework version

Python 3.12

Platform

Windows (x86_64)

OS/Browser version

Windows 11

Describe the bug

I'm making a face recognition system with voice verification as well. It has a recognize user, register user and delete user function, where register user collects a new face and voice profile, and recognize user verifies the face and voice and see if they match. (Same user as this one)

When I run my app in my computer, the program works fine. However, when I deployed my app into gradio, the following error appeared whenever PvRecorder is required (which is when the user's face has been verified and the next step is to verify the voice to ensure they match).

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/gradio/queueing.py", line 407, in call_prediction
    output = await route_utils.call_process_api(
  File "/usr/local/lib/python3.10/site-packages/gradio/route_utils.py", line 226, in call_process_api
    output = await app.get_blocks().process_api(
  File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1550, in process_api
    result = await self.call_function(
  File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1185, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2177, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 859, in run
    result = context.run(func, *args)
  File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 661, in wrapper
    response = f(*args, **kwargs)
  File "/home/user/app/app.py", line 100, in recognize_user
    recognizer_recorder = PvRecorder(device_index=-1, frame_length=eagle.frame_length)
  File "/usr/local/lib/python3.10/site-packages/pvrecorder/_pvrecorder.py", line 112, in __init__
    raise self._PVRECORDER_STATUS_TO_EXCEPTION[status]("Failed to initialize PvRecorder.")
RuntimeError: Failed to initialize PvRecorder.

The app.py file can be accessed here

Help would be greatly appreciated!

Steps To Reproduce

The web app can be accessed here. Register your face and voice first (don't worry, the database only stores a number array and not the face itself) then switch to verify user and wait until the app asks you to speak (and that's when the error pops out).

Expected Behavior

When the user speaks in the verify user section after his/her face is verified, a message should show up saying Access is granted.

ErisMik commented 2 months ago

PvRecorder uses Miniaudio as it's backend to provide platform support, so if Miniaudio doesn't support running in Gradio then PvRecorder won't work either.

Eagle itself isn't dependent on PvRecorder specifically, we just use it in our demos to make cross platform support easier. Any audio source providing or converted into the right data format and sample rate will work. I would assume that Gradio has it's own audio recording interface/api? I would suggest trying to use that.

LongMingWei commented 2 months ago

Oh yeah, you are right, should have realised that sooner. Thank you!

laves commented 2 months ago

Closing as this was not an issue with Eagle