API Functions
API Mode
To use Rybená programmatically, we suggest starting the script with the mode=api parameter This option automates several functions to use Rybená via API
These automations include:
- Opening of Rybená in background
- Removal of Rybená's presentation texts
Example:
<script type="text/javascript" src="https://cdn.rybena.com.br/dom/master/latest/rybena.js?mode=api"></script>
How it works
The rybená API was structured to work through function calls through a single controller. This controller is only available to be called after the solution opening request.
TIP
It is possible to automate the opening of the rybená solution with the following function:
RybenaDOM.getInstance().getRybenaScripts()
To open Rybená in the background, just pass the "hidden" parameter to the function:
RybenaDOM.getInstance().getRybenaScripts("hidden")
Functions
After Rybena is started, it is possible to access the controller with the function:
RybenaAPI.getInstance()
Afterwards, simply call the functions for Rybená to perform the respective actions
Set Rybená's visibility
- Show Rybená:
RybenaApi.getInstance().openPlayer()
- Hide Rybená:
RybenaApi.getInstance().closePlayer()
Set Player transparency
We have two transparency modes:
- Default mode: Player with header and action buttons:
RybenaApi.getInstance().setToNormalMode()
- Transparent mode: Player without header and action buttons:
RybenaApi.getInstance().setToTransparentMode()
ATTENTION
In this mode, Rybená will not have its translation control functions, and it will not be possible to interact with Rybená.
Set Rybená's coordinates
- Set Rybená's position to the desired location:
RybenaApi.getInstance().setCoordinates(x, y)
Set translation type
- Translation into pounds:
RybenaApi.getInstance().switchToLibras()
- Voice synthesis:
RybenaApi.getInstance().switchToVoz()
Manage translation
- Translate a text:
RybenaApi.getInstance().translate(“text”)
- Pause the translation of a text:
RybenaApi.getInstance().pause()
- Start translating a text again:
RybenaApi.getInstance().play()
- Stop translating a text:
RybenaApi.getInstance().stop()
ATTENTION
The difference between the Pause and Stop functionality is:
- Pause: Just pause the rybená, and when you execute the play function it will translate from where you paused
- Stop: Clears Rybená's translation buffer, and when you execute the play function it will not play anything
Define translation variations
- Modify translation speed (float)
Accepted values
- 0.5: Half speed
- 0.75: Slow
- 1: Normal
- 1.25: Fast
- 1.5: Very fast
RybenaApi.getInstance().setSpeed(speed)
Advanced translation handlers
- Configure a function to be executed when the Rybena finishes loading:
RybenaApi.getInstance().handleLoaded(() => {})
- Check if avatar is translating:
RybenaApi.getInstance().isTranslating()
- Configure some function to be executed when the avatar stops translating:
RybenaApi.getInstance().handleTranslate(() => {})
TIP
As a parameter it is necessary to pass the function to be executed. To do this, simply pass the reference to the function, not its execution: Ex: pass func, not func()
Player size handlers
- Modify the player size proportionally
RybenaApi.getInstance().setSize(value)
Initialize in another language
This option changes the startup language of the Rybená solution
lang: ptBR → Initializes the solution in Portuguese lang: esES → Initialize the solution in Spanish lang: enUS → Initializes the solution in English
Example:
<script type="text/javascript" src="https://cdn.rybena.com.br/dom/master/latest/rybena.js?lang=ptBR"></script>
Default value: ptBR
ATTENTION
Only the Portuguese language contains the LIBRAS translation functionality