dtokenizer
discretize everything into tokens
Introduction
dtokenizer is a Python library designed to discretize audio files into tokens using various models. It supports models like Hubert and Encodec for tokenization.
Installation
To use dtokenizer, first ensure you have Python and pip installed. Then, install the required dependencies by running:
pip install -r requirements.txt
Usage
Hubert Tokenizer
The Hubert tokenizer can be used to tokenize audio files into discrete tokens and then decode them back. Here's how you can use it:
from dtokenizer.audio.model.hubert_model import HubertTokenizer
import soundfile as sf
ht = HubertTokenizer('hubert_layer6_code100')
code, decodec_stuff = ht.encode_file('./sample2_22k.wav')
wav_values = ht.decode(code)
# Write the decoded audio to a file
sf.write('output.wav', wav_values, 16000)
Encodec Tokenizer
Similarly, the Encodec tokenizer allows for efficient audio file tokenization. Here's an example of its usage:
import torch
from dtokenizer.audio.model.encodec_model import EncodecTokenizer
import torchaudio
et = EncodecTokenizer('encodec_24k_6bps')
code, stuff_for_decode = et.encode_file('./sample2_22k.wav')
wav_values = et.decode(stuff_for_decode)
# Save the decoded audio to a file
torchaudio.save('output.wav', torch.from_numpy(wav_values), 22050)
Contributing
We welcome contributions to the dtokenizer project. Please feel free to submit issues or pull requests.
License
This project is released under the MIT License. See the LICENSE file for more details.
Metadata
Release files for dtokenizer 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dtokenizer-0.0.6.tar.gz | 15.1 kB | Without provenance | Details for dtokenizer-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dtokenizer-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for dtokenizer-0.0.6-py3-none-any.whl |
Total release size: 35.4 kB
Release files / dtokenizer-0.0.6.tar.gz
| Download URL | dtokenizer-0.0.6.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d800c475ecaf2ec6f1d1fc0060d2aadd4f218556213a8dfea4c1869253eb473c
|
|
BLAKE2b-256 checksum How to use checksums |
4ac1b0f69b87d91ba84a46bfe7b925fbc51326590493f938bbc48c090ca2be03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.5
|
Release files / dtokenizer-0.0.6-py3-none-any.whl
| Download URL | dtokenizer-0.0.6-py3-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
679388a733fe94f3137bce77102bd2d6787f10d48457c6f6c24ec3f3139acf05
|
|
BLAKE2b-256 checksum How to use checksums |
3aca7ba55ac54043c8a475c2dcc32b778a8de32953eeccb4d6aa005aa916d1e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.5
|
Security for dtokenizer 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.