Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error for each supported audio file type #113

Closed
duysqubix opened this issue Oct 11, 2023 · 4 comments
Closed

Error for each supported audio file type #113

duysqubix opened this issue Oct 11, 2023 · 4 comments

Comments

@duysqubix
Copy link
Contributor

I have tried running functional audio files for a .flac, .mp3 and .wav but receive different errors for each one. My code is pretty much the same for the 3 different tests:

package main

import(
  "fmt"
  "time"
  "os"
  "github.com/faiface/beep/<file type>"
  "github.com/faiface/beep/speaker"
)

func main() {
  openFile, openFileErr := os.Open("<path/to/file>")
  if openFileErr != nil {
    fmt.Println("FILE OPEN ERROR", openFileErr)
    return
  }
  streamer, format, streamerErr := <file type>.Decode(openFile)
  if streamerErr != nil {
    fmt.Println("AUDIO STREAMER ERROR", streamerErr)
    return
  }
  speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))
  speaker.Play(streamer)
  select{}
}

Expected:
Audio plays normally.

WAV Result:
wav: missing data chunk marker

MP3 Result:
mp3: mp3: only layer3 (want 1; got 3) is supported

Flac Result:
flac: flac.parseStreamInfo: invalid FLAC signature; expected "fLaC", got "RIFF"

Here are the files for your own use:
Flac file
MP3 file
WAV file

All the files are generated by the IBM Watson text-to-speech API and run fine on my machine. All error messages occur within the AUDIO STREAMER ERROR block. Is this a bug? Thanks!

Original issue: faiface/beep#11

@MarkKremer
Copy link
Contributor

MarkKremer commented Oct 12, 2023

Mostly solved in original issue. I will need the correct audio files to reproduce the other problems. Closing for now.

@punkscience
Copy link

Just a heads up in case anyone else winds up here. While it may not be OPs original problem, I too was running into all sorts of playback errors on some mp3s. The reason was because I was trying to use mp3.Decode() on every file type. It only makes sense now that I realize there is a different module for each file type. So my solution was to simply switch on the file extension and use the appropriate decoder for the appropriate file type.

@clseibold
Copy link

clseibold commented Apr 6, 2024

It seems I'm getting the mp3 error mp3: mp3: only layer3 (want 1; got 3) is supported on mp3 files that should work. mpg123 is able to play the files correctly (because another software program I use is able to play the files), but this library has issues with them. They should be mp1 data, so I don't know why the error would be implying they are layer1.

Also important: the error message doesn't make sense. It says only layer3 is supported, but then it says it got 3, and yet it want 1. Why would it want layer1 if it only supports layer 3? Why would it not be playing if it got layer3, which is supposedly supported according to the error message.
Either way, the error message is incorrect. Perhaps 1 and 3 are being reversed and it really got 1 and wanted 3.

I can provide a file that fails if needed.

@clseibold
Copy link

clseibold commented Apr 6, 2024

I found this same issue from the older hajimehoshi/go-mp3 repo. It looks like one of the bugs was fixed by @hajimehoshi by skipping ID3v2 tags, as shown in this issue: hajimehoshi/go-mp3#9
I'm not sure what my issue is.

Also, looks like it doesn't skip LAME's padding: hajimehoshi/go-mp3#25

Also, I suggest that y'all look into using/porting minimp3, because it supports MP1, MP2, and MP3, and it is significantly more performant, as shown in this issue: hajimehoshi/go-mp3#21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants