SPX
audio/speex
Magic Bytes
Offset: 0
4F 67 67 53 00 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 2E 53 70 65 65 78 20 20 20
Speex (SPX) is an open-source patent-free audio compression format specifically designed for speech and maintained by the Xiph.Org Foundation. This format is primarily utilized in Voice over IP applications, internet telephony, and podcasting due to its efficiency in encoding human voice at low bitrates. Although now deprecated in favor of the Opus codec, the format is considered safe provided that playback software is updated to handle legacy Ogg containers securely.
Validation Code
How to validate .spx files in Python
Python
def is_spx(file_path: str) -> bool:
"""Check if file is a valid SPX by magic bytes."""
signature = bytes([0x4F, 0x67, 0x67, 0x53, 0x00, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x53, 0x70, 0x65, 0x65, 0x78, 0x20, 0x20, 0x20])
with open(file_path, "rb") as f:
return f.read(36) == signature
How to validate .spx files in Node.js
Node.js
function isSPX(buffer: Buffer): boolean {
const signature = Buffer.from([0x4F, 0x67, 0x67, 0x53, 0x00, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x53, 0x70, 0x65, 0x65, 0x78, 0x20, 0x20, 0x20]);
return buffer.subarray(0, 36).equals(signature);
}
Go
func IsSPX(data []byte) bool {
signature := []byte{0x4F, 0x67, 0x67, 0x53, 0x00, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x53, 0x70, 0x65, 0x65, 0x78, 0x20, 0x20, 0x20}
if len(data) < 36 {
return false
}
return bytes.Equal(data[:36], signature)
}
API Endpoint
GET
/api/v1/spx
curl https://filesignature.org/api/v1/spx