Python SDK for speech2text.ru
Project description
Speech2Text Python SDK
Python SDK for API [speech2text.ru](https://speech2text.ru).
## Installation
```
pip install speech2text_client
```
## Usage
```python
from speech2text_client.client import Speech2Text
from speech2text_client.options import RecognizeOptions
from speech2text_client.enums import Formats
api = Speech2Text('YOUR_API_KEY')
options = RecognizeOptions("ru", [1, 2], False)
task = api.recognitions().send_file("test.mp3", options)
result = task.wait().result(Formats.TXT)
print(result)
```
### Show tasks lists
```python
from speech2text_client.client import Speech2Text
from speech2text_client.enums import ListStages
api = Speech2Text('YOUR_API_KEY')
print(api.recognitions().list(limit=10, page=1)) # return last 10 tasks
print(api.recognitions().list(stage=ListStages.COMPLETE.value)) # return completed tasks
print(api.recognitions().list(stage=ListStages.PROCESSING.value)) # return tasks in process
```
### Show tasks information
```python
from speech2text_client.client import Speech2Text
api = Speech2Text('YOUR_API_KEY')
task_id = 'TASK_ID'
task = api.recognitions().task(task_id)
print(f"Id: {task.id()}")
print(f" Status: {task.status().code} ({task.status().description})")
print(f" Type: {task.source_type()}")
print(f" Options:")
print(f" Language: {task.recognize_options().lang}")
print(f" Stereo: {task.recognize_options().stereo}")
print(
f" Speakers: {task.recognize_options().speakers if isinstance(task.recognize_options().speakers, int) or task.recognize_options().speakers is None else f'from {task.recognize_options().speakers[0]} to {task.recognize_options().speakers[1]}'}")
print(f" Mime: {task.meta().mime}")
print(f" File format: {task.meta().format}")
print(f" Audio format: {task.meta().audio_format}")
```
### Show tasks results
```python
from speech2text_client.client import Speech2Text
from speech2text_client.enums import Formats
api = Speech2Text('YOUR_API_KEY')
task_id = 'TASK_ID'
task = api.recognitions().task(task_id)
print(task.result(Formats.TXT)) # txt
print("=" * 50)
print(task.result(Formats.RAW)) # raw
print("=" * 50)
print(task.result(Formats.SRT)) # srt
print("=" * 50)
print(task.result(Formats.VTT)) # vtt
print("=" * 50)
print(task.result(Formats.JSON)) # json
print("=" * 50)
print(task.result(Formats.XML)) # xml
```
### Work with user and settings
```python
from speech2text_client.client import Speech2Text
api = Speech2Text("YOUR_API_KEY")
print(f"Balance: {api.user().amounts().balance()}")
print(f"Available Minutes: {api.user().amounts().available_minutes()}")
print(f"Used Minutes: {api.user().amounts().used_minutes()}")
print(f"Rate: {api.user().rate().title} ({api.user().rate().minutes} minutes for {api.user().rate().period} day(s))")
print(f"Threads: {api.user().settings().threads()}")
print(f"Auto payment status: {'Yes' if api.user().settings().auto_payments_status() else 'No'}")
print(f"Auto payment ON: {'вњ…' if api.user().settings().auto_payments_on() else 'вќЊ'}")
print(f"Auto payment OFF: {'вњ…' if api.user().settings().auto_payments_off() else 'вќЊ'}")
```
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
File details
Details for the file speech2text_client-0.1.5.tar.gz.
File metadata
- Download URL: speech2text_client-0.1.5.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eef5055189e4d75d39ee99c3e51994c8ce3c3b8ccbabbbd83594e0ec93e1dcfd
|
|
| MD5 |
872e4e4017268181e6291667107f6192
|
|
| BLAKE2b-256 |
5bc50ae632f1772e736799285aa3a8f89de9f3852df2bcf6bf1156f1261f5aa6
|