Use Language Translation Session

After establishing a WebRTC connection in Connect With WebRTC, you can initialize a conversation for simultaneous language translation with Sanas.

First, start by sending a reset message on the WebRTC data channel:

{
  type: 'reset'
  reset: {
    id: string                 // This should be an arbitrary UUID generated by you
    lang_in: string | null     // The original language code in ISO 639-1 format, automatically inferred if null
    lang_out: string           // The translation language code in ISO 639-1 format
    glossary?: string[] | null // An optional list of brand names to preserve
    detect_languages: bool     // Enable language identification pipeline to get language probabilities at regular intervals
  }
}

Then, wait to receive a ready message back from the server on the WebRTC data channel with a matching id. The message should look like so:

{
  type: 'ready'
  ready: {
    id: string            // The id that you specified in the reset message
  }
}

You are now ready to start feeding audio through the WebRTC audio channel! You will then start receiving audio back.

Additionally, you will receive the following messages on the data channel for transcripts and translations:

With the Word object like so:

And with the IdentifiedLanguage object like so:

To end a session, simply stop the WebRTC connection.

spinner

Last updated