Commit 9af61a33 authored by Arnie97's avatar Arnie97

support silk audio

parent 774a1e32
package global
import (
log "github.com/sirupsen/logrus"
"bytes"
"io/ioutil"
"os"
"path"
)
var IMAGE_PATH = path.Join("data", "images")
log "github.com/sirupsen/logrus"
)
var VOICE_PATH = path.Join("data", "voices")
var (
IMAGE_PATH = path.Join("data", "images")
VOICE_PATH = path.Join("data", "voices")
VIDEO_PATH = path.Join("data", "videos")
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)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment