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

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.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (474.9 kB view details)

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

k2py-0.2.2-cp314-cp314-macosx_15_0_arm64.whl (311.3 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

k2py-0.2.2-cp313-cp313-win_amd64.whl (302.4 kB view details)

Uploaded CPython 3.13Windows x86-64

k2py-0.2.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (474.6 kB view details)

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

k2py-0.2.2-cp313-cp313-macosx_15_0_arm64.whl (310.7 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

k2py-0.2.2-cp312-cp312-win_amd64.whl (302.4 kB view details)

Uploaded CPython 3.12Windows x86-64

k2py-0.2.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (473.8 kB view details)

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

k2py-0.2.2-cp312-cp312-macosx_15_0_arm64.whl (310.7 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

k2py-0.2.2-cp311-cp311-win_amd64.whl (301.5 kB view details)

Uploaded CPython 3.11Windows x86-64

k2py-0.2.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (473.2 kB view details)

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

k2py-0.2.2-cp311-cp311-macosx_15_0_arm64.whl (310.5 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

k2py-0.2.2-cp310-cp310-win_amd64.whl (300.9 kB view details)

Uploaded CPython 3.10Windows x86-64

k2py-0.2.2-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.2-cp310-cp310-macosx_15_0_arm64.whl (309.1 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for k2py-0.2.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 235612b87beebe27d65072fd635c02941845b013ae7ae1c0343bf3cbe8c48ca7
MD5 b1eaf9dc732e5c5a718239928e3b7b9e
BLAKE2b-256 1af9484c5e4ef59208fe645edc5636f382426894b4856db626703d785c88ce22

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.2-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9e141649aa815fb9bb090a3ae13aec9196e707fa0d5e3ad42fdf1c4da9ed60e5
MD5 cb87d8d107ba0eca05eb37b3e4890d03
BLAKE2b-256 f9d512dbbc1dddb5ff115d68eb507ef02a922aaa5dee6a78b828d2f682b04abf

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: k2py-0.2.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 302.4 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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4e68c05e3517b35b05d7b4066c2097a2491dc288a21e9b56204cbd7a899f19bf
MD5 ed4ec1c3b275d9009e89c7c0e366f08c
BLAKE2b-256 9c0f71d3de1b90b38d714319bd8c56223a3ae204e4852ab81000e2d202c05775

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bd319be8c24cee3dd22e329af01a37b830fb59950948179f74f97f2a45f5e60e
MD5 4676d0512995feda4b5fb16003ca5089
BLAKE2b-256 b6e2b7a746c044178309eaa72e6d1930ac1932bb73561793cbb9893c03e77756

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 cf7ede43b154fb701078147abed03148be00366f9082570b9b63c47d717d1ad4
MD5 44236e66124d6044a0a692430ad6e055
BLAKE2b-256 6eca92f00bcbb5d645d395e5b7007c5c03b1e9d5538b10eb4453dca39f83d472

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: k2py-0.2.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 302.4 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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ae162a34a0b4e0aef5fec95766b31a99f855ce9d7eca99191d15e75bffd5b154
MD5 aa4ef91bd8910562dd14f469ab76a4e9
BLAKE2b-256 fa51b074800c0fb51424c11d250c80017e5027e4a6e782b8794f30fb72016bf1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d177a52d207714b626cc17b22c281417bcd992b0431e7bd33181ca9350612d87
MD5 d24958d83362816106e8d28e39fc7598
BLAKE2b-256 e9b3472a43e7770966de407ce3cce7d56cdd90cb2fe759000511b060d5f8cbd1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 dd8476b78e6f609c05c2c68fa56d5d9d98e7830913f4885290f4a7e16c476555
MD5 13c142c1b4dd0ec72c83637e8ce04dd2
BLAKE2b-256 1fc0a5cfe939679ea64bccfeb65c55fd2504653a1df79c63a1ecdcb38c856298

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: k2py-0.2.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 301.5 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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dbdc9820480a91783633f74da27395caef0db1508bccf86fc1cd85d1da7dc93c
MD5 28390565d5f925f9d72f826291107a9e
BLAKE2b-256 40eb8d09221f649d28e8d3ee4449ec152de60162c8e95e86bbd90c3e980720ae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2d72de68cac98544e1c0e6e859de8388eebb6cefb39ea70fc5d3abfb0e29f065
MD5 7c9cdfdd58f66677183d1fc6af848098
BLAKE2b-256 229bed7c65d95b6f89afe399521e76bb211e97c2e3ffa7335b8bc9ff2124c85f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.2-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bdaa5725dcc356f4cb863347ed576eb2b4eb066347b604cd14117feed57fcbfe
MD5 480c64f1f0e0f18ee859a777e057dae5
BLAKE2b-256 ee42d165220c1cc5034c78b757e83f8b48b99f9fc107154703b928fca6c331ee

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: k2py-0.2.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 300.9 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.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 14c4ff3832f18bd7c928f3f178645fc8a7aa076d449640874444b13423b43805
MD5 e5e89d820ab4e7ec28c232ecd4538519
BLAKE2b-256 c09bed874784a19ff95f42bc5860c8c068771336424fb64078be683b09763b29

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 28bd9eca2bd0d9b698bb33fe1935e1972124ab22c05f01f9e38c391985c12db4
MD5 0f56ef4773b4a8cd58b9f929916356f5
BLAKE2b-256 e84aa581e68493cc2a258478d5a22e0db74a931c21f5e7572d95c584764b8a1d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.2-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 09cd559ff54eaec4cff24cf51d1c2a69cbf895fbbaf4108d3dfbd3c5e00d788c
MD5 94ffadbd27b59d624281bef582a772db
BLAKE2b-256 72dbfb336dda697630822181a413b795a98222d8e5c7d84d03581ee839883b9e

See more details on using hashes here.

Provenance

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