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

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

k2py-0.2.1-cp314-cp314-macosx_15_0_arm64.whl (310.9 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

k2py-0.2.1-cp313-cp313-win_amd64.whl (302.1 kB view details)

Uploaded CPython 3.13Windows x86-64

k2py-0.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (473.7 kB view details)

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

k2py-0.2.1-cp313-cp313-macosx_15_0_arm64.whl (310.4 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

k2py-0.2.1-cp312-cp312-win_amd64.whl (302.1 kB view details)

Uploaded CPython 3.12Windows x86-64

k2py-0.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (473.2 kB view details)

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

k2py-0.2.1-cp312-cp312-macosx_15_0_arm64.whl (310.4 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

k2py-0.2.1-cp311-cp311-win_amd64.whl (301.2 kB view details)

Uploaded CPython 3.11Windows x86-64

k2py-0.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (471.5 kB view details)

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

k2py-0.2.1-cp311-cp311-macosx_15_0_arm64.whl (310.4 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

k2py-0.2.1-cp310-cp310-win_amd64.whl (302.5 kB view details)

Uploaded CPython 3.10Windows x86-64

k2py-0.2.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (470.3 kB view details)

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

k2py-0.2.1-cp310-cp310-macosx_15_0_arm64.whl (309.0 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

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

File metadata

File hashes

Hashes for k2py-0.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2dac092e7c531ea4f7ec252fcf53ea472f517355f3a24567bbaadb24673feb4e
MD5 a4f33ace490d4e5803b68e79f842f91d
BLAKE2b-256 68504c484df1d0dab11c7fd9ce7ab348170b55b34ec570dac535a027ebd017e5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.1-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 24449840926a8d423774d6ea00cefdf451afc8184fe8deeb8ea1fbc0e33abef2
MD5 5e488be881f61c201aa64ec4597aa5a4
BLAKE2b-256 a7c8c9ea2a5dbb661d0fc6b94f7f714e96e0e18dd929deb940187f61fe6e2bf0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: k2py-0.2.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 302.1 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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6e2f527ba39d3ab7126db68afc75e6faaa45436510736d12e3237fbd7c6df3e1
MD5 28570202ce02682edaf34ce68054ee18
BLAKE2b-256 8050ff87a74300f81f6ecd52bf7f0944b40a260232a2f27121a0a58b148177ea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9628de0815afc678e0ec65e9e32aad509a6790b9d1ae7b2489817acf4ec43c70
MD5 06d4974983242fb979e0f1181109f24e
BLAKE2b-256 b4fca08444ff2bda1caf5af037c334e47a66da6dc9ca470c7b8f8a5562b19ece

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b8aa887e2b4a6213a2f4b4be7c55d48107d3ac40269c9428050e7a718a0c7990
MD5 50a7eb97e552b98edb2ffd07d4bf581c
BLAKE2b-256 8249ffbabcbcd4e4630b92fa9038136fe09a46b39810c9bf83ffa48de8df1622

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: k2py-0.2.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 302.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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 778626a49256011bb89155ab966ff7e8f91adcf4cf31a584d298496761c53c89
MD5 fc9b6c8eaf5adb87143c327925492327
BLAKE2b-256 84b4d07b7c10b4ae5d55bdbd41f1e7faf943af19a068f47c1e1e20e65c7cea56

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 98237022ad3db9108758d10a70a144119cce7ba99850df1c5345146264d0fee3
MD5 62c9913c11bcb71913e08b426d5bdf89
BLAKE2b-256 d04286c79debda96cfc1b1fa165f03ec287af5bb2b8333b4db5d1160f6b98f68

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bae1fc9f2a77e39770e04498d737089b91f0a5cd8cc293e3a4861bdc8c816562
MD5 fc43991b817f104090a1a0eb97c0a9b6
BLAKE2b-256 c5da59c4d34e8feb81538bf8481a4333c00b80785e2a456b4a61f45674000d1b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: k2py-0.2.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 301.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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 96c333ff6de0a8cfe4ebed6f69eda54138dc567950de569aae3da7240082f88f
MD5 9e0e50eea39f084e34f1a7a5c178cca0
BLAKE2b-256 8b56d76b2267e33c3ce03635d90036ba1c634fd030280d779cb30aa988f4d301

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 681fb086f35920325379818d47673612de18a44498123d7436b4ccbc03fef0a2
MD5 a84d791fe454dee271a5af4f57c326e3
BLAKE2b-256 2e3ce67ae5cf202e3883bb1c5f560c1d488cf329839717594534275897700e56

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1768633d96ef982c8c6c09728eb0ca5297a170dddff5d951bdb311e50f96b98f
MD5 b766bda516a13bf8b373703b2c9e8088
BLAKE2b-256 4ff1aad23829ac528827e844222506f1a9743d49ca10d369de1600ec33d63b17

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: k2py-0.2.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 302.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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c68098e41de8bc8fa370c640cda148e13cf5881909e24e62500bc24889e2ba92
MD5 1b09db890445f36e339b6a8a682d0254
BLAKE2b-256 c5e7a1caed440f978c687c223ade88dbafb5811b5c17dce7994c7f20fab5e0c4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a28389859ff5de44cfdb6e1def21987b91f830032990e94dfba4994510a1d242
MD5 3c6d872bcca0cac69df5c9d497343fae
BLAKE2b-256 1862ee316531fdd7c80e695d3fb9a35c3359be2d3123d213225383a07593db01

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for k2py-0.2.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 07e4d7a16a7c2993b3d159bcc4b37b50414c291e9636ac4f65bc5c4c9c4007a1
MD5 02a7ef2aca1badfc695c05918c47e232
BLAKE2b-256 38cc2ea4eb717c81b06a2e14550b58764e98816b1eea905f274c78fab5887a67

See more details on using hashes here.

Provenance

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