Closed wayloree closed 7 months ago
@RoyceGenius, Hi, can you send me the file you are trying to process? Also send information about your system and processor architecture. I just tried to recognize audio sent to a telegram bot and I don’t see any problems, I think I can help you with information about you file and system.
My code:
@dp.message_handler(content_types=[types.ContentType.VOICE])
async def recognize_song(message: types.Message):
voice = await message.voice.download()
info = await shazam.recognize(voice.name)
try:
image = info['track']['images']['coverarthq']
title = info['track']['title']
subtitle = info['track']['subtitle']
url = info['track']['url']
await bot.send_photo(
chat_id=message.from_user.id,
photo=image,
caption=f"Track: {subtitle} - {title}\n"
f"[Play in Apple Music]({url})\n",
parse_mode='Markdown',
)
except NotFoundTrack:
await bot.send_message(chat_id=message.from_user.id, text='Song not found...')
Also, please post a minimal example of what you are doing to reproduce the problem that is occurring with the bot.
So, I tried using different mic, but it didn't help. What I'm doing now is just basically trying to launch a code from your example. I didn't code myself anything at all now, just trying to understand why the problem occurs. error:
here is the link to file test34.mp3 I just recorded it from my phone. Also I am using i5-9400f, but I don't think it is a problem here https://www.mediafire.com/file/qlnf1nwmk8g6wq9/test34.mp3/file
@RoyceGenius Install please ffmpeg :)
oh, yeah.. I forgot about it.. didn't know it can give such an issue. my bad, thanks!
I tried using shazamio for my Telegram project and got this error. Whenever I use straight up music files like downloaded from youtube or some music website everything works perfectly, but when I try to record a voice message on my mic with music playing in it I get this error every time. I thought maybe there is something wrong with my code, with voice message handler in telegram bot, but no. I even used the example code from here to recognize track in an empty file. Works fine with simple just-music files and can't handle a microphone one with track playing in it. Any solution?
import asyncio from shazamio import Shazam async def main(): shazam = Shazam() out = await shazam.recognize('test.mp3') print(out)
loop = asyncio.get_event_loop() loop.run_until_complete(main())`
Error: Traceback (most recent call last): File "main.py", line 12, in
loop.run_until_complete(main())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "main.py", line 8, in main
out = await shazam.recognize('test4.mp3') # rust version, use this!
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\shazamio\api.py", line 534, in recognize
signature = await self.core_recognizer.recognize_path(data)
SignatureError: end of stream