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.6-cp314-cp314-win_amd64.whl (318.2 kB view details)

Uploaded CPython 3.14Windows x86-64

k2py-0.2.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (481.2 kB view details)

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

k2py-0.2.6-cp314-cp314-macosx_15_0_arm64.whl (323.4 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

k2py-0.2.6-cp313-cp313-win_amd64.whl (308.8 kB view details)

Uploaded CPython 3.13Windows x86-64

k2py-0.2.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (481.3 kB view details)

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

k2py-0.2.6-cp313-cp313-macosx_15_0_arm64.whl (322.6 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

k2py-0.2.6-cp312-cp312-win_amd64.whl (308.8 kB view details)

Uploaded CPython 3.12Windows x86-64

k2py-0.2.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (481.2 kB view details)

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

k2py-0.2.6-cp312-cp312-macosx_15_0_arm64.whl (322.5 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

k2py-0.2.6-cp311-cp311-win_amd64.whl (307.2 kB view details)

Uploaded CPython 3.11Windows x86-64

k2py-0.2.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (478.7 kB view details)

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

k2py-0.2.6-cp311-cp311-macosx_15_0_arm64.whl (322.0 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

k2py-0.2.6-cp310-cp310-win_amd64.whl (306.5 kB view details)

Uploaded CPython 3.10Windows x86-64

k2py-0.2.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (477.6 kB view details)

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

k2py-0.2.6-cp310-cp310-macosx_15_0_arm64.whl (320.6 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

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

File metadata

  • Download URL: k2py-0.2.6-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 318.2 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.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 ee2708b8b298b4c2d5031835445db04c21a1a1eb1f967123c16ee31c94b9f086
MD5 3016f0bfdc725001610f97948c008578
BLAKE2b-256 7ba39718ada74acb517096dcc53dc2b220d6cd414a55e77385bc3f69ad159ccf

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for k2py-0.2.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e4e3e6d27049aefc1d5349edcce8ae51ffcb7403db42c4cd0f7dc332f7fdd8d
MD5 67e000ced8f4fc3c82d917477b15ea61
BLAKE2b-256 5c0476b0e0a6972b10c20e42937055f53dcc79a6aee6568047c478c4f74716ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for k2py-0.2.6-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b1e62c70b30d97611128d7a184a1e3edb6290646dbdecfbcd1498e62e396b514
MD5 b14a1c119d5857e69968714b3bb1f38b
BLAKE2b-256 360d9cdc2a27d7fe1bcc7b19af62ddd95db85078ae48dac079909c83cac2cec1

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: k2py-0.2.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 308.8 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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 22542c9a063c691593430a3f9d67f7734944476ad7d0ada754263ed2be318f73
MD5 b6a4dbaa7beedc84343348217d045e1e
BLAKE2b-256 2eb25ea919bd1c160d40fdf07ad5833b9d84550e04d6b2fb7f6eb7ace2d92640

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for k2py-0.2.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3e226ee0c2a9ff5c52da39a5a8f71e0b728539a88de54850cba6bf939c0251a3
MD5 634dba644c4cd34f034f0a74a65a919a
BLAKE2b-256 5ab49cc2d26cc65d1eebc526d4c057f467577d618407f10c3fedbf9f8463107e

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for k2py-0.2.6-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6d2db820d027b72a3e6e010c7fdda82d01457d83bee29d7a06073c62c49eb604
MD5 6c62beacab3362d9a18c1c5dc6136d01
BLAKE2b-256 9a414f895c0ae30237e769e2cba31530bfecfe50588137836b0eba0ed795f976

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: k2py-0.2.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 308.8 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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5d6e417752344494222bc9e2461c8df5da4c6d9ef05eda4f85952aad8b4689c5
MD5 2301e615914588e7579a13912df6a9c6
BLAKE2b-256 656e6715c7834569b0fb3b5bcd8a11436e8af1fb419a419e49b5994ee5e646c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for k2py-0.2.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b82a867511d928407458d7e0dc8537565091df447a4f6b72e639e29193837449
MD5 a570f63f74d24b34c277003218b4dd12
BLAKE2b-256 e329685a11ce1166f7810309c8f147d14e44185abb2d9fafeb7cbcf1a79a03fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for k2py-0.2.6-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0c448c09f2705fe20392d5969fe037d710029f502ac43a907a8ff97396c07a65
MD5 976c3511fc4084a698597720141ad6f8
BLAKE2b-256 6be6c5bb011cc2aa0384f20f824e767b33df01eac0d29aaca91737f4f1ba87b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: k2py-0.2.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 307.2 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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 69a14da5d7218b2270af0e1443aa48940265b2a416799bd506990b2af3effca6
MD5 2951a05a2c5077c5df4cf888d24c9493
BLAKE2b-256 b6628cfb3d3cdb98dc688b6ff43418461368bc03f9b9f7a3a2789b9a4a7ba4fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for k2py-0.2.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1d58993666704b9002918641035ac0f68e2afd8201a77f62239e6a6d77f2a948
MD5 e71fa76b70abde6376e7b701c271c1f6
BLAKE2b-256 c34bba72f61c4145984a19f13a0817d1c61c325a7aac2a25f3a4385d475b317d

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for k2py-0.2.6-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f2639e5b2a22df5d1225b0232ed8374cb97754423cc11d3547ad7e901d663c55
MD5 43aacecdbb336759866ebdb85a34cd56
BLAKE2b-256 e72335736ca147ca9f38d96365bfcf0bb4ed4d29bf1a056fc17e6f8e384b6e06

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: k2py-0.2.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 306.5 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.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d2ced5cb4e1afc9d05470de86002c828ce5cd009fc23025e32ca4621352a751d
MD5 24af8b432a70a5f22d23afbf743cc089
BLAKE2b-256 00b55b77720b8da4cbc36a31d7388c8e0790bbd0f75f275f2fb3c874447c0e00

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for k2py-0.2.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c55f2b3df13fceeaee0c2114a937f51a6c73cd4d2f5b52cb61c8c146021feefd
MD5 698db117977e19d9329ca927ffa96f32
BLAKE2b-256 04b587cb1ea58a230182f83892b1474d6c166ece4aa4105fd0c449e0ed960b75

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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.6-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for k2py-0.2.6-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 784d42abd2fa83d24bfaa01b1417c11de6fd456a6ed87daa13569653b39ee190
MD5 c93a7cca3d658f188ff9d1350635425d
BLAKE2b-256 af10c94b482d4e76cceeb30eecc65f12e1608057810d52414889d3bd95852522

See more details on using hashes here.

Provenance

The following attestation bundles were made for k2py-0.2.6-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