Currently, active work is underway to unload the processor; searching for a signature is a complex operation for the CPU, especially for a language where there is an asynchronous approach, because of this, asynchrony for the recoginze method disappears.
What has already been done:
The search for song signatures from Python to Rust has been rewritten.
integration of this module through pyo3, as is done with pydantic.
There is very little left, but now you can see the preliminary results.
Before
Test for 20 iterations.
async def main():
shazam = Shazam()
t = time.perf_counter()
a = await asyncio.gather(*[shazam.recognize_song("data/dora.ogg") for _ in range(20)]) # blocking code
t2 = time.perf_counter()
print(t2-t)
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
>>> 23.145966300013242
After:
Test for 50 iterations.
async def main():
sender = rust.Recognizer()
t = time.perf_counter()
a = await asyncio.gather(*[sender.recognize_path("data/dora.ogg") for _ in range(50)])
t2 = time.perf_counter()
print(t2 - t)
Recognize from Python to Rust
Currently, active work is underway to unload the processor; searching for a signature is a complex operation for the CPU, especially for a language where there is an asynchronous approach, because of this, asynchrony for the
recoginze
method disappears. What has already been done: The search for song signatures from Python to Rust has been rewritten. integration of this module through pyo3, as is done with pydantic.There is very little left, but now you can see the preliminary results.
Before
Test for 20 iterations.
After:
Test for 50 iterations.