GoShazam is a Go library that provides an interface to the Shazam music recognition service. It allows you to recognize songs from audio files using Shazam's powerful audio fingerprinting technology.
- Recognize songs from audio files (MP3, WAV, OGG)
- Generate audio fingerprints
- Interface with Shazam's API
- Return full JSON response for maximum flexibility
To install GoShazam, use go get
:
go get github.com/kuudori/goshazam
Here's a basic example of how to use GoShazam:
package main
import (
"context"
"fmt"
"log"
"github.com/kuudori/goshazam"
)
func main() {
client := goshazam.NewShazamClient()
result, err := client.Recognize(context.Background(), "test.mp3")
if err != nil {
log.Fatalf("Error recognizing audio: %v", err)
}
rawResult := result.Raw() // Get raw JSON response
fmt.Println(string(rawResult))
serializedResult, _ := result.Serialize() // Serialize response
fmt.Println(serializedResult)
// keep it short
// client.Recognize(context.Background(), "test.mp3").Serialize()
// client.Recognize(context.Background(), "test.mp3").Raw()
}
For more detailed examples, please check the examples
folder in the repository.
GoShazam supports recognizing songs from the following audio formats:
- MP3
- WAV
- OGG
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This library is for educational and personal use only. Make sure you comply with Shazam's terms of service when using this library.