From 966cb871f098b25984e7a4b555af07049d51eb4f Mon Sep 17 00:00:00 2001 From: Sreeram Date: Thu, 23 Nov 2023 19:04:01 +0530 Subject: [PATCH] fix: return if buffer is empty while Loading --- loader.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/loader.go b/loader.go index 56f9d06..6ec0b7a 100644 --- a/loader.go +++ b/loader.go @@ -52,6 +52,11 @@ func (l *Loader) Load(src interface{}) (*AudioSegment, error) { return nil, fmt.Errorf("expected `io.Reader` or file path to original audio") } + // Empty buffer + if len(buf) == 0 { + return nil, nil + } + // Try to decode it as wave audio waveAudio, err := wav.DecodeFromBytes(buf) if err != nil {