Python SDK for Yandex Speechkit API.
Project description
Python SDK for Yandex SpeechKit API. This SDK allows you to use the cloud API for speech recognition and synthesis from Yandex.
For more information please visit Yandex Speechkit API Docs. This lib supports short and long audio recognition with speechkit
🛠 Getting Started
Assuming that you have Python and virtualenv
installed, set up your environment and install the required dependencies
like this, or you can install the library using pip
:
$ git clone https://github.com/TikhonP/yandex-speechkit-lib-python.git
$ cd yandex-speechkit-lib-python
$ virtualenv venv
...
$ . venv/bin/activate
$ python -m pip install -r requirements.txt
$ python -m pip install .
python -m pip install speechkit
📑 Speechkit documentation
Check out speechkit docs for more info. PDF docs
🔮 Using speechkit
There are support of recognizing long and short audio and synthesis. For more information please read docs below.
First you need create session for authorisation:
from speechkit import Session
oauth_token = str('<oauth_token>')
folder_id = str('<folder_id>')
api_key = str('<api-key>')
jwt_token = str('<jwt_token>')
oauth_session = Session.from_yandex_passport_oauth_token(oauth_token, folder_id)
api_key_session = Session.from_api_key(api_key, x_client_request_id_header=True, x_data_logging_enabled=True)
# You can use `x_client_request_id_header` and `x_data_logging_enabled` params to troubleshoot yandex recognition
# Use `Session.get_x_client_request_id()` method to get x_client_request_id value.
jwt_session = Session.from_jwt(jwt_token)
Use created session to make other requests.
There are also functions for getting credentials (read Documentation for more info):
Speechkit.auth.generate_jwt
, speechkit.auth.get_iam_token
, speechkit.auth.get_api_key
For audio recognition
Short audio:
from speechkit import ShortAudioRecognition
recognizeShortAudio = ShortAudioRecognition(session)
with open(str('/Users/tikhon/Desktop/out.wav'), str('rb')) as f:
data = f.read()
print(recognizeShortAudio.recognize(data, format='lpcm', sampleRateHertz='48000'))
# Will be printed: 'text that need to be recognized'
Look at example with long audio long_audio_recognition.py .
Look at example with streaming audio streaming_recognize.py
For synthesis
from speechkit import SpeechSynthesis
synthesizeAudio = SpeechSynthesis(session)
synthesizeAudio.synthesize(
str('/Users/tikhon/Desktop/out.wav'), text='Text that will be synthesised',
voice='oksana', format='lpcm', sampleRateHertz='16000'
)
🔗 Links
💼 License
In other words, you can use the code for private and commercial purposes with an author attribution (by including the original license file).
Feel free to contact us via email tikhon.petrishchev@gmail.com.
❤️
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file speechkit-2.2.2.tar.gz
.
File metadata
- Download URL: speechkit-2.2.2.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 481780cf97f52eacef616c19e26e2a6b32e1bb7bc70e9a968f7a2b64dab37b25 |
|
MD5 | 9f98250cde2845406114d2fa61ae20c8 |
|
BLAKE2b-256 | 703deffb878ed80887d9e3cd63cde938298d0788292f9e6217eee9b0dae59f21 |
File details
Details for the file speechkit-2.2.2-py3-none-any.whl
.
File metadata
- Download URL: speechkit-2.2.2-py3-none-any.whl
- Upload date:
- Size: 42.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc7f8ffbd5cc40b403b87cdfa2b869f7646d1432232edc72eca4efc8141d48a3 |
|
MD5 | e822ab8730ea2f5ab9004e23fdef9270 |
|
BLAKE2b-256 | 37b22943431db1416329fffa19ef48281c24d764dfeaa1ed135d4ed2ab90b503 |