Crates.io | wacr |
lib.rs | wacr |
version | 2.2.1 |
source | src |
created_at | 2022-10-02 14:21:04.521445 |
updated_at | 2022-11-12 16:05:41.711841 |
description | The backend for WebRTC -> VK ASR (speech recognition technology) interaction. |
homepage | |
repository | https://github.com/Mnwa/wacr |
max_upload_size | |
id | 678334 |
size | 141,879 |
WACR is the backend for WebRTC -> VK ASR (speech recognition technology) interaction.
The client just calls to WACR backend by WebRTC technology. After that WACR save an audio stream from WebRTC to file system. Saved audio stream will send to VK ACR backend by API. Then WACR save in-memory recognized text and send it to client.
cargo install wacr
RUST_LOG=debug;VK_API_SERVICE_TOKEN=XXX;VK_API_SERVICE_KEY=YYY wacr
RUST_LOG=debug;VK_API_SERVICE_TOKEN=XXX;VK_API_SERVICE_KEY=YYY cargo run --package wacr --bin wacr
cargo build --package wacr --bin wacr --release
RUST_LOG=debug;VK_API_SERVICE_TOKEN=XXX;VK_API_SERVICE_KEY=YYY ./target/release/wacr
Query must be extracted from mini apps launch params
POST http://127.0.0.1:8080/token/generate
Content-Type: application/json
{
"query": "XXX"
}
{
"token": "xxx",
"expiration": 1664718489
}
Creating connection by WebRTC. access_token must be got from Get JWT Token API. Offer is client local WebRTC offer.
POST http://127.0.0.1:8080/session/create?access_token=XXX
Content-Type: application/json
{
"offer": {}
}
{
"session_id": "a3b26e68-7fda-4534-bbdd-92a98230a824",
"offer": {}
}
Start recognising of speech accepted from Create session. access_token must be got from Get JWT Token API.
POST http://127.0.0.1:8080/session/asr?access_token=XXX
Content-Type: application/json
{
"session_id": "a3b26e68-7fda-4534-bbdd-92a98230a824"
}
{
"text": "Hello world!"
}
GET http://127.0.0.1:8080/session/listen/{session_id}?access_token=XXX
{
"error": "error occurred"
}
VK_API_SERVICE_TOKEN=XXX # Service token for requesting VK API endpoints
VK_API_SERVICE_KEY=YYY # Service key for validating query on token generation
LISTEN_ADDRESS=127.0.0.1:8080 # Listening address
JWT_EXPIRATION=3600 # How many seconds access token will valid
GARBAGE_COLLECTOR_TTL=3600 # How many seconds audio files and text results will alive
SESSION_KEEP_ALIVE_TIMEOUT=10 # How many seconds webrtc session will alive without incoming packets
SESSION_TOTAL_TIMEOUT=100 # Max number of seconds webrtc session will alive
AUDIO_DIR=/tmp # The directory where audio files saving
WEBRTC_PORT_MIN=0 # Minimal available port for webrtc peer connections
WEBRTC_PORT_MAX=0 # Maximal available port for webrtc peer connections
WEBRTC_INTERFACES_ALLOWED= # All interfaces allowed by default. List of allowed network interfaces split by ,
STATIC_DIR= # If set, service will distribute all static from this directory by path /static. Example: /static/index.html