-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(Cargo.lock): Add arc-swap, portable-atomic, pyo3-log packages
🔧 fix(Cargo.lock): Update pyo3, pyo3-build-config, pyo3-ffi, pyo3-macros, pyo3-macros-backend versions to 0.20.3 🔧 fix(pyproject.toml): Update shazamio_core version to 1.1.0-rc.2 🔧 fix(Cargo.toml): Update shazamio-core version to 1.1.0-rc.2, add pyo3-log and log dependencies 🔧 fix(src/lib.rs): Add logging initialization and messages, update segment duration to 10 seconds 🔧 fix(src/fingerprinting/algorithm.rs): Update segment duration to 10 seconds 🔧 fix(shazamio_core/shazamio_core.py): Update segment duration to 10 seconds, add type hints and docstrings 🔧 fix(shazamio_core/shazamio_core.pyi): Update segment duration to 10 seconds, add type hints and docstrings 🔧 fix(.github/workflows/CI.yml): Update comments for macOS targets
- Loading branch information
Showing
8 changed files
with
154 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "shazamio_core" | ||
version = "1.1.0-rc.1" | ||
version = "1.1.0-rc.2" | ||
description = "" | ||
authors = ["dotX12 <[email protected]>"] | ||
readme = "README.md" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,83 @@ | ||
from dataclasses import dataclass | ||
from typing import Union | ||
from os import PathLike | ||
|
||
|
||
@dataclass | ||
class Geolocation: | ||
altitude: int | ||
latitude: int | ||
longitude: int | ||
|
||
|
||
@dataclass | ||
class SignatureSong: | ||
samples: int | ||
timestamp: int | ||
uri: str | ||
|
||
|
||
@dataclass | ||
class Signature: | ||
geolocation: Geolocation | ||
signature: SignatureSong | ||
timestamp: int | ||
timezone: str | ||
|
||
|
||
class SignatureError(Exception): | ||
def __init__(self, message: str): | ||
self.message = message | ||
|
||
def __str__(self) -> str: | ||
return self.message | ||
|
||
def __repr__(self) -> str: | ||
return f"SignatureError({self.message})" | ||
|
||
|
||
class Recognizer: | ||
def __init__(self, segment_duration_seconds: int = 12) -> None: | ||
""" | ||
Recognizer uses a Rust implementation under the hood. | ||
This class provides an interface for recognizing audio files, but the actual | ||
processing logic is implemented in Rust and accessed via FFI. | ||
""" | ||
|
||
def __init__(self, segment_duration_seconds: int = 10) -> None: | ||
""" | ||
:param segment_duration_seconds: The duration (in seconds) of the audio segment to analyze. | ||
- **Default:** 12 seconds. | ||
- **If the audio file is longer than this duration**, a centered segment of the specified duration is selected. | ||
- Example: If the audio is **60 seconds** and `segment_duration_seconds = 10`, the extracted segment will be **from 25s to 35s**. | ||
- **If the audio file is shorter than this duration**, the entire file is used. | ||
- Example: If the audio is **8 seconds** and `segment_duration_seconds = 10`, the entire **8-second file** will be processed. | ||
- **Audio is always converted to mono and downsampled to 16 kHz** before analysis. | ||
- This parameter determines the number of samples used for frequency analysis and fingerprint generation. | ||
""" | ||
self.segment_duration_seconds = segment_duration_seconds | ||
raise NotImplemented | ||
|
||
async def recognize_path(self, value: str) -> Signature: | ||
async def recognize_path(self, value: Union[str, PathLike]) -> Signature: | ||
""" | ||
:param value: path file | ||
:return: Signature object | ||
:raises SignatureError: if there is any error | ||
Recognize audio from a file path. | ||
This method is a Python wrapper around a Rust implementation. | ||
:param value: Path to an audio file. | ||
:return: Signature object. | ||
:raises SignatureError: if an error occurs. | ||
""" | ||
raise NotImplemented | ||
|
||
async def recognize_bytes(self, value: bytes) -> Signature: | ||
""" | ||
:param value: bytes file | ||
:return: Signature object | ||
:raises SignatureError: if there is any error | ||
Recognize audio from raw bytes. | ||
This method is a Python wrapper around a Rust implementation. | ||
:param value: Raw audio file as bytes. | ||
:return: Signature object. | ||
:raises SignatureError: if an error occurs. | ||
""" | ||
raise NotImplemented |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.