Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kisasexypantera94/khalzam
Simple audio recognition library.
https://github.com/kisasexypantera94/khalzam
Last synced: about 2 months ago
JSON representation
Simple audio recognition library.
- Host: GitHub
- URL: https://github.com/kisasexypantera94/khalzam
- Owner: kisasexypantera94
- License: mit
- Created: 2018-12-24T03:55:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-18T14:02:12.000Z (about 5 years ago)
- Last Synced: 2024-06-20T16:50:33.895Z (3 months ago)
- Language: Go
- Size: 24.4 KB
- Stars: 46
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - kisasexypantera94/khalzam - Simple audio recognition library. (Go)
README
# Khalzam
This library is very poorly designed and was written purely as proof-of-concept.
I have rewritten it in Rust and the main development is going [here](https://github.com/kisasexypantera94/khalzam-rs).## About
Khalzam is a simple audio recognition library. Its algrorithm is based on
[this article](https://www.toptal.com/algorithms/shazam-it-music-processing-fingerprinting-and-recognition) by Jovan Jovanovic## Dependencies
Fingerprint library uses mpg123 (thinking of switching to a native solution) so you need to install it:
#### macOS (Homebrew)
```
$ brew install mpg123
```
#### Debian
```
$ sudo apt-get install libmpg123-dev
```## Setup
You need to create and initialize database:
```
$ createdb -O user databasename
$ psql -f createdb.sql databasename
```## Usage
#### Shell mode
```
$ DBUSER=kisasexypantera94 DBNAME=khalzam go run shell.go
Initializing library...MusicLibrary interactive shell
>>> helpCommands:
clear clear the screen
delete delete audio from database
exit exit the program
help display help
index index audiofile
indexdir index directory
recognize recognize audiofile
recognizedir recognize directory>>> index resources/Modjo\ -\ Lady\ \(Hear\ Me\ Tonight\).mp3
Indexing 'resources/Modjo - Lady (Hear Me Tonight).mp3'...
>>> recognize samples/modjo_lady_sample.mp3
Recognizing 'samples/modjo_lady_sample.mp3'...
Best match: Modjo - Lady (Hear Me Tonight) (11% matched)
```#### API
```golang
package mainimport (
"fmt"
"github.com/kisasexypantera94/khalzam/musiclibrary"
_ "github.com/lib/pq"
)func main() {
cfg := &musiclibrary.Config{
User: os.Getenv("DBUSER"),
Password: os.Getenv("DBPASSWORD"),
DBname: os.Getenv("DBNAME"),
Host: os.Getenv("DBHOST"),
Port: os.Getenv("DBPORT"),
}musicLib, _ := musiclibrary.Open(cfg)
defer musicLib.Close()musicLib.Index("resources/Modjo - Lady (Hear Me Tonight).mp3")
result := musicLib.Recognize("samples/modjo_lady_sample.mp3")
fmt.Println(result)
}
```