alfred82santa / whalesong

Whalesong is an asyncio python library to manage WebApps remotely. Currently WhatsappWeb is implemented
https://whalesong.readthedocs.io
MIT License
51 stars 19 forks source link

send_media with audio file fails / How to send audio? #58

Closed DSchndr closed 5 years ago

DSchndr commented 5 years ago

When you send any file with audio mime type sending fails. (Seems like the download function in the minibot example also cannot handle mp3 send.)

How about an send_audio function where the file gets sent like an voice recording?

alfred82santa commented 5 years ago

Have you tried an ogg audio file?

alfred82santa commented 5 years ago

You are right Whalesong can not send audio files like voice recordings, I mean, it can not send PushToTalk messages. But, I've tested minibot with this message:

/download https://sample-videos.com/audio/mp3/crowd-cheering.mp3

And it works like a PushToTalk message. Examples are just examples, they don't try to be perfect, so it is possible you are using a url which responses with a composed content-type (audio/ogg; codecs=opus) header and whatsappweb fails. Could you post your url?

DSchndr commented 5 years ago

i think mine was also https://sample-videos.com/audio/mp3/crowd-cheering.mp3 wierd that it crashed in my case.

alfred82santa commented 5 years ago

imatge

Does it still happen to you? I will need more info.

alfred82santa commented 5 years ago

Any news here?

DSchndr commented 5 years ago

Minibot and my own bot still fail to send the file as ptt message. Trying to send an mp3 over waweb also fails in my case ("unsupported file"), so maybe there is something in waweb code that is being retarded?


Traceback (most recent call last):
  File "examples/minibot.py", line 133, in make_download
    message.id)))
whalesong.errors.UnknownError
alfred82santa commented 5 years ago

Well, if WhatsApp Web fails there is nothing we can do. But is strange, it works in my case. Which OS do you use? And browser?

DSchndr commented 5 years ago

Firefox 64.0 (64-bit), Ubuntu 18.04 LTS

MP4 upload doesn't work in selenium window, but in normal window it works which is kinda wierd. In normal chrome window everything works, so i think maybe firefox version is a little bit too old and waweb code detects this or firefox interferes with it somehow?

Edit: Ok, i've tried chromium backend -> mp4 send fails because of "unsupported file type" Error is a little bit more informative this time ;) (whalesong.errors.UnknownError: InvalidMediaFileType: ExtendableError)

At least sending mp3 as ptt message works in chromium.

alfred82santa commented 5 years ago

Finally, I've found the problem, at least in Firefox. Default Firefox profile template disabled all codecs. Now it should work for all codecs supported by ffmpeg.

On the other hand, I guess we can not solve problem with h.264 codec on Chronium: https://www.chromium.org/audio-video

I didn't find way to enable ffmpeg at runtime.

alfred82santa commented 5 years ago

Could you test it?

alfred82santa commented 5 years ago

Maybe, best option would be transcode files before to send them...

DSchndr commented 5 years ago

Thanks, with enabled codecs everything works on firefox!

tulssinep commented 4 years ago

Hey, running into the same issue with Safari on Desktop at the moment. I can send MP3 but not OGG. Is there anything I can do about it or is there a list of supported audio codecs?

DSchndr commented 4 years ago

Use ffmpeg to transcode the files into mp3 format or use firefox.