Golang
Update:
Overview
This document will guide developer using the real-time voice translation SDK (RTVT) from LiveData, to implement translation services in real-time voice scenarios.
Integration
Service Activation
To integration the LiveData RTVT SDK, you need to register an personal/enterprise account from LiveData official website (https://www.ilivedata.com/) , create a real-time voice translation service project and update the corresponding project parameters in SDK.
Version Support
go 1.21.2 and above.
Requirements
- Audio format : Support PCM OPUS audio format
- Sampling rate: 16KHz
- Bytes: 640byte
- Encoding: 16-bit depth
- Channels: Monaural
CreateRTVTClient
func CreateRTVTClient(endpoints string, callbacks RTVTCallback, logger RTVTLogger) *RTVTClient
param
description
endpoints
the address and port to rtvt eg. rtvt.ilivedata.com:14001
callbacks
callback interface
logger
internal logger interface
Login
func (client *RTVTClient) Login(pid int32, timestamp int64, token string) bool
param
description
pid
the pid of your project eg. 81700001
timestamp
timestamp
token
auth token
StartTranslate
func (client *RTVTClient) StartTranslate(asrResult bool, tempResult bool, transResult bool, srcLanguage string, srcAltLauguage []string, destLanguage string, userId string, vadSlienceTime int64, codec AudioCodec) (int64, error)
param
description
asrResult
if true, you can get the recognize result.
tempResult
if both asrResult and temp Result are true. you can get the recognize temp result. If both tempResult and transResult are true, you can get the translate temp result.
transResult
if true, you can get the translate result.
srcLanguage
source language
srcAltLanguage
alternative languages
destLanguage
destination language
userId
user id, can be empty
vadSlienceTime
vad time. -1 means not use vad cut. 200-2000 means use the vad cut sentence. (milliseconds)
codec
the codec of audio data
SendData
func (client *RTVTClient) SendData(streamId int64, data []byte, seq int64, timestamp int64) error
param
description
streamId
the streamId you get from StartTranslate
data
PCM data
seq
sequence of the package
timestamp
timestamp of the package
EndTranslate
func (client *RTVTClient) EndTranslate(streamId int64) error
param
description
streamId
the streamId you get from StartTranslate
Error code
Error code
Description
800000
Unknown error
800002
Unverified link
800003
Invalid parameter
800101
Invalid system time
800102
Invalid token, invalid encoding
800103
Invalid pid
800105
Unsupported language
800106
Too many alternative languages
800107
Translation stream reached the limit
800200
StreamId does not exist
More information
For SDK download and more information, please go to Github.
Overview
This document will guide developer using the real-time voice translation SDK (RTVT) from LiveData, to implement translation services in real-time voice scenarios.
Integration
Service Activation
To integration the LiveData RTVT SDK, you need to register an personal/enterprise account from LiveData official website (https://www.ilivedata.com/) , create a real-time voice translation service project and update the corresponding project parameters in SDK.
Version Support
go 1.21.2 and above.
Requirements
- Audio format : Support PCM OPUS audio format
- Sampling rate: 16KHz
- Bytes: 640byte
- Encoding: 16-bit depth
- Channels: Monaural
CreateRTVTClient
func CreateRTVTClient(endpoints string, callbacks RTVTCallback, logger RTVTLogger) *RTVTClient
param | description |
---|---|
endpoints | the address and port to rtvt eg. rtvt.ilivedata.com:14001 |
callbacks | callback interface |
logger | internal logger interface |
Login
func (client *RTVTClient) Login(pid int32, timestamp int64, token string) bool
param | description |
---|---|
pid | the pid of your project eg. 81700001 |
timestamp | timestamp |
token | auth token |
StartTranslate
func (client *RTVTClient) StartTranslate(asrResult bool, tempResult bool, transResult bool, srcLanguage string, srcAltLauguage []string, destLanguage string, userId string, vadSlienceTime int64, codec AudioCodec) (int64, error)
param | description |
---|---|
asrResult | if true, you can get the recognize result. |
tempResult | if both asrResult and temp Result are true. you can get the recognize temp result. If both tempResult and transResult are true, you can get the translate temp result. |
transResult | if true, you can get the translate result. |
srcLanguage | source language |
srcAltLanguage | alternative languages |
destLanguage | destination language |
userId | user id, can be empty |
vadSlienceTime | vad time. -1 means not use vad cut. 200-2000 means use the vad cut sentence. (milliseconds) |
codec | the codec of audio data |
SendData
func (client *RTVTClient) SendData(streamId int64, data []byte, seq int64, timestamp int64) error
param | description |
---|---|
streamId | the streamId you get from StartTranslate |
data | PCM data |
seq | sequence of the package |
timestamp | timestamp of the package |
EndTranslate
func (client *RTVTClient) EndTranslate(streamId int64) error
param | description |
---|---|
streamId | the streamId you get from StartTranslate |
Error code
Error code | Description |
---|---|
800000 | Unknown error |
800002 | Unverified link |
800003 | Invalid parameter |
800101 | Invalid system time |
800102 | Invalid token, invalid encoding |
800103 | Invalid pid |
800105 | Unsupported language |
800106 | Too many alternative languages |
800107 | Translation stream reached the limit |
800200 | StreamId does not exist |
More information
For SDK download and more information, please go to Github.