# Leopard Binding for Python
## Leopard Speech-to-Text Engine
Made in Vancouver, Canada by [Picovoice](https://picovoice.ai)
Leopard is an on-device speech-to-text engine. Leopard is:
- Private; All voice processing runs locally.
- [Accurate](https://picovoice.ai/docs/benchmark/stt/)
- [Compact and Computationally-Efficient](https://github.com/Picovoice/speech-to-text-benchmark#rtf)
- Cross-Platform:
- Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64)
- Android and iOS
- Chrome, Safari, Firefox, and Edge
- Raspberry Pi (3, 4, 5)
## Compatibility
- Python 3.8+
- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), and Raspberry Pi (3, 4, 5).
## Installation
```console
pip3 install pvleopard
```
## AccessKey
Leopard requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Leopard SDKs.
You can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret.
Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`.
## Usage
Create an instance of the engine and transcribe an audio file:
```python
import pvleopard
leopard = pvleopard.create(access_key='${ACCESS_KEY}')
transcript, words = leopard.process_file('${AUDIO_FILE_PATH}')
print(transcript)
for word in words:
print(
"{word=\"%s\" start_sec=%.2f end_sec=%.2f confidence=%.2f speaker_tag=%d}"
% (word.word, word.start_sec, word.end_sec, word.confidence, word.speaker_tag))
```
Replace `${ACCESS_KEY}` with yours obtained from [Picovoice Console](https://console.picovoice.ai/) and
`${AUDIO_FILE_PATH}` to the path an audio file.
Finally, when done be sure to explicitly release the resources:
```python
leopard.delete()
```
### Language Model
The Leopard Python SDK comes preloaded with a default English language model (`.pv` file).
Default models for other supported languages can be found in [lib/common](../../lib/common).
Create custom language models using the [Picovoice Console](https://console.picovoice.ai/). Here you can train
language models with custom vocabulary and boost words in the existing vocabulary.
Pass in the `.pv` file via the `model_path` argument:
```python
leopard = pvleopard.create(
access_key='${ACCESS_KEY}',
model_path='${MODEL_FILE_PATH}')
```
### Word Metadata
Along with the transcript, Leopard returns metadata for each transcribed word. Available metadata items are:
- **Start Time:** Indicates when the word started in the transcribed audio. Value is in seconds.
- **End Time:** Indicates when the word ended in the transcribed audio. Value is in seconds.
- **Confidence:** Leopard's confidence that the transcribed word is accurate. It is a number within `[0, 1]`.
- **Speaker Tag:** If speaker diarization is enabled on initialization, the speaker tag is a non-negative integer identifying unique speakers, with `0` reserved for unknown speakers. If speaker diarization is not enabled, the value will always be `-1`.
## Demos
[pvleoparddemo](https://pypi.org/project/pvleoparddemo/) provides command-line utilities for processing audio using
Leopard.
Raw data
{
"_id": null,
"home_page": "https://github.com/Picovoice/leopard",
"name": "pvleopard",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "Speech-to-Text, Speech Recognition, Voice Recognition, ASR, Automatic Speech Recognition",
"author": "Picovoice",
"author_email": "hello@picovoice.ai",
"download_url": "https://files.pythonhosted.org/packages/84/76/d0e5d15a9686686a1fb173137e41a5ed738fb774fd70a6d235ff8b727f2a/pvleopard-2.0.3.tar.gz",
"platform": null,
"description": "# Leopard Binding for Python\n\n## Leopard Speech-to-Text Engine\n\nMade in Vancouver, Canada by [Picovoice](https://picovoice.ai)\n\nLeopard is an on-device speech-to-text engine. Leopard is:\n\n- Private; All voice processing runs locally.\n- [Accurate](https://picovoice.ai/docs/benchmark/stt/)\n- [Compact and Computationally-Efficient](https://github.com/Picovoice/speech-to-text-benchmark#rtf)\n- Cross-Platform:\n - Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64)\n - Android and iOS\n - Chrome, Safari, Firefox, and Edge\n - Raspberry Pi (3, 4, 5)\n\n## Compatibility\n\n- Python 3.8+\n- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), and Raspberry Pi (3, 4, 5).\n\n## Installation\n\n```console\npip3 install pvleopard\n```\n\n## AccessKey\n\nLeopard requires a valid Picovoice `AccessKey` at initialization. `AccessKey` acts as your credentials when using Leopard SDKs.\nYou can get your `AccessKey` for free. Make sure to keep your `AccessKey` secret.\nSignup or Login to [Picovoice Console](https://console.picovoice.ai/) to get your `AccessKey`.\n\n## Usage\n\nCreate an instance of the engine and transcribe an audio file:\n\n```python\nimport pvleopard\n\nleopard = pvleopard.create(access_key='${ACCESS_KEY}')\n\ntranscript, words = leopard.process_file('${AUDIO_FILE_PATH}')\nprint(transcript)\nfor word in words:\n print(\n \"{word=\\\"%s\\\" start_sec=%.2f end_sec=%.2f confidence=%.2f speaker_tag=%d}\"\n % (word.word, word.start_sec, word.end_sec, word.confidence, word.speaker_tag))\n```\n\nReplace `${ACCESS_KEY}` with yours obtained from [Picovoice Console](https://console.picovoice.ai/) and\n`${AUDIO_FILE_PATH}` to the path an audio file.\n\nFinally, when done be sure to explicitly release the resources:\n```python\nleopard.delete()\n```\n\n### Language Model\n\nThe Leopard Python SDK comes preloaded with a default English language model (`.pv` file).\nDefault models for other supported languages can be found in [lib/common](../../lib/common).\n\nCreate custom language models using the [Picovoice Console](https://console.picovoice.ai/). Here you can train\nlanguage models with custom vocabulary and boost words in the existing vocabulary.\n\nPass in the `.pv` file via the `model_path` argument:\n```python\nleopard = pvleopard.create(\n access_key='${ACCESS_KEY}',\n model_path='${MODEL_FILE_PATH}')\n```\n\n### Word Metadata\n\nAlong with the transcript, Leopard returns metadata for each transcribed word. Available metadata items are:\n\n- **Start Time:** Indicates when the word started in the transcribed audio. Value is in seconds.\n- **End Time:** Indicates when the word ended in the transcribed audio. Value is in seconds.\n- **Confidence:** Leopard's confidence that the transcribed word is accurate. It is a number within `[0, 1]`.\n- **Speaker Tag:** If speaker diarization is enabled on initialization, the speaker tag is a non-negative integer identifying unique speakers, with `0` reserved for unknown speakers. If speaker diarization is not enabled, the value will always be `-1`.\n\n## Demos\n\n[pvleoparddemo](https://pypi.org/project/pvleoparddemo/) provides command-line utilities for processing audio using\nLeopard.\n",
"bugtrack_url": null,
"license": null,
"summary": "Leopard Speech-to-Text Engine.",
"version": "2.0.3",
"project_urls": {
"Homepage": "https://github.com/Picovoice/leopard"
},
"split_keywords": [
"speech-to-text",
" speech recognition",
" voice recognition",
" asr",
" automatic speech recognition"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0f37add945d3154e9dad1125a9bdb502e10e3cd686ec18d765065ee30a81679f",
"md5": "b92ace0745c02507941e6ebfd7af5943",
"sha256": "7934e7c3246c54b8a81cb7acd492968c7720452bc534e380d72ddaedfde011c3"
},
"downloads": -1,
"filename": "pvleopard-2.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b92ace0745c02507941e6ebfd7af5943",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 41411908,
"upload_time": "2024-09-16T18:51:58",
"upload_time_iso_8601": "2024-09-16T18:51:58.718272Z",
"url": "https://files.pythonhosted.org/packages/0f/37/add945d3154e9dad1125a9bdb502e10e3cd686ec18d765065ee30a81679f/pvleopard-2.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8476d0e5d15a9686686a1fb173137e41a5ed738fb774fd70a6d235ff8b727f2a",
"md5": "d2447869daf41be2ce72e180f82e69e7",
"sha256": "f7c8a459d020986f8f61f55aac227dc141e1af452ea13826dfb201cc411802b3"
},
"downloads": -1,
"filename": "pvleopard-2.0.3.tar.gz",
"has_sig": false,
"md5_digest": "d2447869daf41be2ce72e180f82e69e7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 41399789,
"upload_time": "2024-09-16T18:52:06",
"upload_time_iso_8601": "2024-09-16T18:52:06.791069Z",
"url": "https://files.pythonhosted.org/packages/84/76/d0e5d15a9686686a1fb173137e41a5ed738fb774fd70a6d235ff8b727f2a/pvleopard-2.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-16 18:52:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Picovoice",
"github_project": "leopard",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pvleopard"
}