Rhymen / go-whatsapp

WhatsApp Web API
MIT License
2.05k stars 490 forks source link

Working example of AudioMessage #526

Closed Jefferson-Henrique closed 3 years ago

Jefferson-Henrique commented 3 years ago

Hello guys, could someone provide a fully functional example of a AudioMessage. I have done one but it is not working anymore, I was converting a mp3 file to a ogg (opus codec), it was working nice until I started to receive this response "audio upload failed: upload responsed with %!d(float64=404)".

I think would be great to also send as a merge request to the examples folder of this repo. Thanks!

Ased2235 commented 3 years ago

Can you show me your code? Cuz mine is working fine

Jefferson-Henrique commented 3 years ago

Sure, this is what I was using.

        audioFile, _ := os.Open("output.opus")

    msg := whatsapp.AudioMessage{
        Info: whatsapp.MessageInfo{
            RemoteJid: to,
        },
        Type:    "audio/ogg; codecs=opus",
        Content: audioFile,
        Ptt:     true,
        Length:  2,
    }

    if _, err := v.wac.Send(msg); err != nil {
        fmt.Fprintf(os.Stderr, "error sending message: %v\n", err)
    }
Ased2235 commented 3 years ago

Does that file exists?

Jefferson-Henrique commented 3 years ago

Yep, it exists, I double checked.

Jefferson-Henrique commented 3 years ago

Can you share an audio file that you used? I could try it, maybe it is some problem with the generated .opus (it is the same that I used before, but... who knows hahaha)

rhsobr commented 3 years ago

I'm facing a similar issue: the voice recorded (audio/ogg; codecs=opus) plays at WhatApp Web but does not in WhatsApp app into device.

Have anyone found this fix?

rhsobr commented 3 years ago

Hello guys, could someone provide a fully functional example of a AudioMessage. I have done one but it is not working anymore, I was converting a mp3 file to a ogg (opus codec), it was working nice until I started to receive this response "audio upload failed: upload responsed with %!d(float64=404)".

I think would be great to also send as a merge request to the examples folder of this repo. Thanks!

Does the error throw while uploading file or when sending message? It could be an error with unknown RemoteJid, instead of file.

rhsobr commented 3 years ago

I'm facing a similar issue: the voice recorded (audio/ogg; codecs=opus) plays at WhatApp Web but does not in WhatsApp app into device.

Have anyone found this fix?

My issue is related to this: https://www.chromestatus.com/feature/5730124735447040#details

Jefferson-Henrique commented 3 years ago

Hello guys, could someone provide a fully functional example of a AudioMessage. I have done one but it is not working anymore, I was converting a mp3 file to a ogg (opus codec), it was working nice until I started to receive this response "audio upload failed: upload responsed with %!d(float64=404)". I think would be great to also send as a merge request to the examples folder of this repo. Thanks!

Does the error throw while uploading file or when sending message? It could be an error with unknown RemoteJid, instead of file.

It is on upload phase, I can send normal messages just fine.