Skip to main content

Python bindings for k2

Project description

k2py

Python bindings for k2

Features

  • Efficient Streaming Decoding: OnlineDenseIntersecter for real-time forced alignment
  • Cross-Platform: Supports Linux, macOS, and Windows
  • Python 3.10+: Compatible with modern Python versions
  • Built with pybind11: Fast C++ bindings with minimal overhead

Installation

From PyPI

pip install k2py

Coexistence with k2

k2py can coexist with the k2 package. Both can be imported in any order:

import k2
import k2py  # works fine

Usage

Basic Example

from k2py import OnlineDenseIntersecter, CreateFsaVecFromStr
import numpy as np

# Create FSA from string representation
fsa_str = "0 1 1 1.0\n1 2 2 1.0\n2"
result = CreateFsaVecFromStr(fsa_str, final_state=2)

# Initialize decoder
decoder = OnlineDenseIntersecter(
    result["fsa"],
    result["aux_labels"],
    search_beam=20.0,
    output_beam=8.0,
    min_active_states=30,
    max_active_states=10000
)

# Prepare acoustic scores (num_frames x vocab_size)
scores = np.random.randn(100, 50).astype(np.float32)

# Decode
lattice = decoder.DecodeWithArray(scores, return_lattice=True)

# Get final alignment result
alignment = decoder.Finish()
print(f"Token IDs: {alignment['token_ids']}")
print(f"Timestamps: {alignment['timestamps']}")
print(f"Durations: {alignment['durations']}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

k2py-0.2.5-cp314-cp314-win_amd64.whl (312.1 kB view details)

Uploaded CPython 3.14Windows x86-64

k2py-0.2.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (473.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

k2py-0.2.5-cp314-cp314-macosx_15_0_arm64.whl (316.2 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

k2py-0.2.5-cp313-cp313-win_amd64.whl (303.2 kB view details)

Uploaded CPython 3.13Windows x86-64

k2py-0.2.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (473.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

k2py-0.2.5-cp313-cp313-macosx_15_0_arm64.whl (315.2 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

k2py-0.2.5-cp312-cp312-win_amd64.whl (303.1 kB view details)

Uploaded CPython 3.12Windows x86-64

k2py-0.2.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (473.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

k2py-0.2.5-cp312-cp312-macosx_15_0_arm64.whl (314.9 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

k2py-0.2.5-cp311-cp311-win_amd64.whl (301.7 kB view details)

Uploaded CPython 3.11Windows x86-64

k2py-0.2.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (474.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

k2py-0.2.5-cp311-cp311-macosx_15_0_arm64.whl (314.7 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

k2py-0.2.5-cp310-cp310-win_amd64.whl (300.7 kB view details)

Uploaded CPython 3.10Windows x86-64

k2py-0.2.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (472.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

k2py-0.2.5-cp310-cp310-macosx_15_0_arm64.whl (313.1 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file k2py-0.2.5-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: k2py-0.2.5-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 312.1 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for k2py-0.2.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1e9927a8961b5ee29832e60c4514d45a752af26924b8aaff15f420f08b15d239
MD5 98b9026374b95822b81767ecb998fa0d
BLAKE2b-256 6515cb7bbe1a6b21d1dcd336a9bd5bee66b6cd2c6bafdfb4cb8cfd4d21b48972

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp314-cp314-win_amd64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for k2py-0.2.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 267461eea2c1bc9eff73141d4fd33a11334055be6b9b586e1e0ba86f2b0826c2
MD5 f25344a69e701082e90ede619ad8a20c
BLAKE2b-256 69888fc5c043f639fe1b8db1ce0e0dbee190e9b4ad0b70e94bd595c4eaca88d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for k2py-0.2.5-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 77b0b3db3b6d0836beeaddf9e11909c8255c1380bed08366d321037e00d44731
MD5 3fa9e14525b647a75a9210ceba8fb899
BLAKE2b-256 071f09d157947bf101697c823a4807c9cb43a5099dd99ece2053159ef89c6bb3

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp314-cp314-macosx_15_0_arm64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: k2py-0.2.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 303.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for k2py-0.2.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 349fefdc22ea736df003935f957c8fc7fcdae116e13d6837f7b3d528ca5c4d68
MD5 b44e9c0cb0af2a609a9c85a87f4d7d17
BLAKE2b-256 b05cafd50da7aed0225cda98975de4924a12f93002965c9d809328c7d0f45bbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp313-cp313-win_amd64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for k2py-0.2.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e634498741383d109da8ca5a63cdaf708066fa426f521ed8718c7f425bc1f42
MD5 f46bf37f2b6f04f11b28b1452cf41b4e
BLAKE2b-256 9670a24b53831c04c4c4ce22b6148fa9e493a8344798148cecdc27d2ae6d2039

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for k2py-0.2.5-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 354b46b06e738a782bfec03bd5d4a4a77279eefdc0dea554625c9d2d34584288
MD5 37aaa7157de540cc54c258690ba4614c
BLAKE2b-256 1f77d03f4a80bf4d5a2712cef0ef0a68a2e907fe77c63a5c8ac1881d82209883

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp313-cp313-macosx_15_0_arm64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: k2py-0.2.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 303.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for k2py-0.2.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7c0b26aa643f92f1eb5a1a2c5b5b1f965497e35b628d045528fea4f002951bcd
MD5 9fb0ffb8936a360f512dcbd46369ed76
BLAKE2b-256 9a3a0dbfb5c92afff127b43bb75f70551824623ac3ef5767c4b7d031feba0ea7

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp312-cp312-win_amd64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for k2py-0.2.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 852b941dae0df028916657e64bb463c371e100caf986324b3c560ad98b47405f
MD5 69379b5994e1e4faf128575a47fa6dca
BLAKE2b-256 f9ad2e55cd7e81270e7efbdff3fba7fb433c3d879ec68fde4c97fbb2e4725285

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for k2py-0.2.5-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 29be003e6fe3eb330b553abd745ad3ac3ca102d6a82ae476d74f5e6b11e66e66
MD5 0ce6a6c28424393463d4a7326700c00c
BLAKE2b-256 97c5a390f6643c2d4f5184a408eb9c97f42e74a6e7030503c7d268576644eb94

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp312-cp312-macosx_15_0_arm64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: k2py-0.2.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 301.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for k2py-0.2.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 56e45665372456a4d5b9c8d47fe63a09668d54f07517bb0361a3e510dd5a7f6f
MD5 05b045917df0adea4948b71e9c895bc5
BLAKE2b-256 5fc539d0ea2300b268fed706cd1e073d77a968a50ff4329a1dfec641e4e91998

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp311-cp311-win_amd64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for k2py-0.2.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52702099b1d4f2be9dc993cb50af41067ff6d0e8bce7cbc316ed3ebee29f5381
MD5 f0c90a1d9ce1d24d4e9e5ca17fbf93c7
BLAKE2b-256 e83f2ba5b1248bbd8dbb17ed41453e7b3bfcdc98573579776c51ec63efc1bcb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for k2py-0.2.5-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d49ee24fd24e25b54cef72095fd0cd7c034f859857a3e3cede65443dc91551ad
MD5 3f853c6542e1586d1d65406e2a6a2b74
BLAKE2b-256 f396bcc9effe490641929c71baa84a49435f0fcbc375f25b3b831aa374b85acf

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: k2py-0.2.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 300.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for k2py-0.2.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e6566dad5b70b69e40903a394c366cbb289669f4a61fdbbb49eeec313471070f
MD5 e8ac4a449b53f6744547650a9fb2a26a
BLAKE2b-256 8c8cc2c7fd225ca7f37a837186efe67b1793ece1465143b2fcf145e80c60b234

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp310-cp310-win_amd64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for k2py-0.2.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 88ded52933a86fca23e34c009b43c494b842593554c9f23ed841ff1d62fc4c7a
MD5 d744dc52f8f2fc8f6c2a9452a3b69960
BLAKE2b-256 f401737cbde267ae24411e27a83f2f4d1dfe2c35e550bf882aa32d2304858e78

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k2py-0.2.5-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for k2py-0.2.5-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b7bdb7e59c4507c1255accb6af36ec0dacff10e315d4a430fdee82bdc0da98ba
MD5 ba20ed5a79830a4d241cd99b59fdd276
BLAKE2b-256 8bb914ae0d0acde889e6f507d0409e4c47ef7d0b253f290013f50f5c86432c7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.5-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: publish-wheels.yml on lattifai/k2py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page