1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-07 12:43:31 +08:00

Merge pull request #99 from mirai-qq/master

support silk audio
This commit is contained in:
Mrs4s 2020-08-17 14:15:11 +08:00 committed by GitHub
commit 5768c61bc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,17 +1,22 @@
package global
import (
log "github.com/sirupsen/logrus"
"bytes"
"io/ioutil"
"os"
"path"
log "github.com/sirupsen/logrus"
)
var IMAGE_PATH = path.Join("data", "images")
var (
IMAGE_PATH = path.Join("data", "images")
VOICE_PATH = path.Join("data", "voices")
VIDEO_PATH = path.Join("data", "videos")
var VOICE_PATH = path.Join("data", "voices")
var VIDEO_PATH = path.Join("data", "videos")
HEADER_AMR = []byte("#!AMR")
HEADER_SILK = []byte("\x02#!SILK_V3")
)
func PathExists(path string) bool {
_, err := os.Stat(path)
@ -37,8 +42,5 @@ func Check(err error) {
}
func IsAMR(b []byte) bool {
if len(b) <= 6 {
return false
}
return b[0] == 0x23 && b[1] == 0x21 && b[2] == 0x41 && b[3] == 0x4D && b[4] == 0x52 // amr file header
return bytes.HasPrefix(b, HEADER_AMR) || bytes.HasPrefix(b, HEADER_SILK)
}