extra features
- easy installation from pypi
- no need for ffmpeg cli installation, pip install is enough
- continious integration and package testing via github actions
setup
pip install pywhisper
You may need rust installed as well, in case tokenizers does not provide a pre-built wheel for your platform. If you see installation errors during the pip install command above, please follow the Getting started page to install Rust development environment. Additionally, you may need to configure the PATH environment variable, e.g. export PATH="$HOME/.cargo/bin:$PATH". If the installation fails with No module named 'setuptools_rust', you need to install setuptools_rust, e.g. by running:
pip install setuptools-rust
command-line usage
The following command will transcribe speech in audio files, using the medium model:
pywhisper audio.flac audio.mp3 audio.wav --model medium
The default setting (which selects the small model) works well for transcribing English. To transcribe an audio file containing non-English speech, you can specify the language using the --language option:
pywhisper japanese.wav --language Japanese
Adding --task translate will translate the speech into English:
pywhisper japanese.wav --language Japanese --task translate
Run the following to view all available options:
pywhisper --help
See tokenizer.py for the list of all available languages.
python usage
Transcription can also be performed within Python:
import pywhisper
model = pywhisper.load_model("base")
result = model.transcribe("audio.mp3")
print(result["text"])
Internally, the transcribe() method reads the entire file and processes the audio with a sliding 30-second window, performing autoregressive sequence-to-sequence predictions on each window.
Below is an example usage of pywhisper.detect_language() and pywhisper.decode() which provide lower-level access to the model.
import pywhisper
model = pywhisper.load_model("base")
# load audio and pad/trim it to fit 30 seconds
audio = pywhisper.load_audio("audio.mp3")
audio = pywhisper.pad_or_trim(audio)
# make log-Mel spectrogram and move to the same device as the model
mel = pywhisper.log_mel_spectrogram(audio).to(model.device)
# detect the spoken language
_, probs = model.detect_language(mel)
print(f"Detected language: {max(probs, key=probs.get)}")
# decode the audio
options = pywhisper.DecodingOptions()
result = pywhisper.decode(model, mel, options)
# print the recognized text
print(result.text)
Metadata
Release files for pywhisper 1.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 |
|---|---|---|---|---|
| pywhisper-1.0.6.tar.gz | 1.2 MB | Without provenance | Details for pywhisper-1.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pywhisper-1.0.6-py3-none-any.whl | Python 3 | none | any | Details for pywhisper-1.0.6-py3-none-any.whl |
Total release size: 2.3 MB
Release files / pywhisper-1.0.6.tar.gz
| Download URL | pywhisper-1.0.6.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea3a653b4d4ec222b561f6cdfef994f86b3ee702af79fd38dff16f4c37bb9f54
|
|
BLAKE2b-256 checksum How to use checksums |
7f96fea31292b346ac750e3f46280310c30edf677ddd9117cc768d1f43270b7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Release files / pywhisper-1.0.6-py3-none-any.whl
| Download URL | pywhisper-1.0.6-py3-none-any.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
395f14ab72a75b6053dcecf7774129d70c682dbfaf37f99169b587b55d97c1da
|
|
BLAKE2b-256 checksum How to use checksums |
5b2788bcb930c8ae212c2850fda6a72df203e6d0df5c2e59dffe8ae236009bd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Security for pywhisper 1.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.