mirror of
https://github.com/cgzirim/seek-tune.git
synced 2025-12-18 09:24:19 +00:00
refactor: simplify WAV conversion and fingerprinting process
This commit is contained in:
parent
c2fc834a0b
commit
8a68843bc6
1 changed files with 10 additions and 5 deletions
|
|
@ -34,19 +34,24 @@ const (
|
||||||
var yellow = color.New(color.FgYellow)
|
var yellow = color.New(color.FgYellow)
|
||||||
|
|
||||||
func find(filePath string) {
|
func find(filePath string) {
|
||||||
wavInfo, err := wav.ReadWavInfo(filePath)
|
wavFilePath, err := wav.ConvertToWAV(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
yellow.Println("Error reading wave info:", err)
|
yellow.Println("Error converting to WAV:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
samples, err := wav.WavBytesToSamples(wavInfo.Data)
|
fingerprint, err := shazam.FingerprintAudio(wavFilePath, utils.GenerateUniqueID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
yellow.Println("Error converting to samples:", err)
|
yellow.Println("Error generating fingerprint for sample: ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
matches, searchDuration, err := shazam.FindMatches(samples, wavInfo.Duration, wavInfo.SampleRate)
|
sampleFingerprint := make(map[uint32]uint32)
|
||||||
|
for address, couple := range fingerprint {
|
||||||
|
sampleFingerprint[address] = couple.AnchorTimeMs
|
||||||
|
}
|
||||||
|
|
||||||
|
matches, searchDuration, err := shazam.FindMatchesFGP(sampleFingerprint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
yellow.Println("Error finding matches:", err)
|
yellow.Println("Error finding matches:", err)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue