Configuring Voice Intuitive v3

Please follow the following instructions to use local configuration for the Voice Intuitive widget


Link to the installation guide


Configuration basics

The Voice Intuitive widget can be configured in numerous ways to alter its features, functionality and appearance. By default, a configuration file containing these settings is retrieved from the server. If you wish, you can override these settings by using a local configuration. The priorities for using different configurations is as follows:

  1. Default configuration. These settings will be used if they are not overriden by settings fetched from the server or local settings.
  2. Settings fetched from the server. Any value specified here will override a corresponding value in the default configuration. If a value is not specified here, the default value will be used.
  3. Local settings that are specified in the installation script. These values will override both default values and the configuration fetched from the server. If a value is not specified here, the system will use a corresponding value from the configuration file fetched from the server and failing that, the default value.

Before using local configuration

Make sure that you read these instructions and have understood them before attempting to use local configuration. The available local configuration settings described in this document may change over time, and it is therefore possible that you will have to manually update the installation script on your website to adjust to these changes.

Using local configuration

Local configuration is specified by feeding the desired configuration object to the widget initializer function as an argument. Here we have a default installation script:

<script>
  (function (w, d, s, o, f, js, fjs) {
  w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments) };
  js = d.createElement(s), fjs = d.getElementsByTagName(s)[0];
  js.id = o; js.src = f; js.async = 1; fjs.parentNode.insertBefore(js, fjs);
  }(window, document, 'script', '_vi', 'https://static.voiceintuitive.com/widget.js'));
  _vi('init');
</script>

Here we have a default installation script with local configuration that turns the "Listen" button green:

<script>
  (function (w, d, s, o, f, js, fjs) {
  w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments) };
  js = d.createElement(s), fjs = d.getElementsByTagName(s)[0];
  js.id = o; js.src = f; js.async = 1; fjs.parentNode.insertBefore(js, fjs);
  }(window, document, 'script', '_vi', 'https://static.voiceintuitive.com/widget.js'));
  _vi('init', {buttonForegroundColor: "#FFFFFF", buttonBackgroundColor: "#006261"});
</script>

By specifying more values in the configuration object it is possible to extensively alter how the script works.

Configuration object and its default values

This is what the default configuration object looks like:


  {
    debug: false,
    skipRemoteConfig: false,
    readAreaSelector: ".voice-intuitive",
    buttonContainerSelector: "#voice-intuitive-root",
    buttonForegroundColor: "#ffffff",
    buttonBackgroundColor: "#000000",
    buttonMargin: "15px 0",
    controlPanelEnabled: true,
    controlPanelShadowColor: "#a9a9a9",
    controlPanelBackgroundColor: "#ffffff",
    controlPanelForegroundColor: "#333333",
    textHighlightingEnabled: false,
    textHighlightDelay: -0.1,
    textHighlightPrimaryColor: '#00000016',
    textHighlightSecondaryColor: '',
    shareButtonEnabled: true,
    useLocalStorageForSpeedSelector: false,
    excludeText: {
      id: [],
      className: ["voice-no-read"],
      tagName: ["STYLE", "SCRIPT", "NOSCRIPT", "IMG", "IMAGE", "IFRAME"],
      elementTextContent: [],
      singleWords:[]
    }
    smallSize:false, 
    prependButtonsInButtonContainer:false,
    extraCSSForListenButton:"",
    extraCSSForTranslateButton:"",
    disabledPaths: [],
    translationAreaSelector: '.voice-intuitive',
    translationButtonMarginBottom: '0',
    useLocalStorageForTranslationLanguage: false,
    hidden: false,
    autoTranslationEnabled: false
  }

Explanation of available settings

If any of the following values are omitted, the widget will retrieve the corresponding value either from the server or use the default value.

debug

Value: Boolean. Setting value to true enables printing various debug messages to the console.

skipRemoteConfig

Value: Boolean. Setting value to true completely skips retrieving configurations from the server. Only values from the local configuration will be used. If a value is missing from local configuration, the default value will be used. Enabling this setting improves performance, as there is no need to wait for the remote server to provide the configuration file.

readAreaSelector

Value: string. Must be a valid CSS selector. This value is used to select the area that the widget will read. While selecting multiple elements in this manner is theoretically possible, it might result in undefined behavior. Ensuring that this selector only matches one element is recommended.

buttonContainerSelector

Value: string. Must be a valid CSS selector. The first (depth-first pre-order traversal) element that matches this selector is where the "Listen" button will appear.

buttonForegroundColor

Value: string. Must be a valid hex color with a value between #000000 and #ffffff. This value is used to select the color of the Voice Intuitive glyph that appears on the "Listen" button.

buttonBackgroundColor

Value: string. Must be a valid hex color with a value between #000000 and #ffffff. This value is used determine the color of the text and the circle on the "Listen" button.

buttonMargin

Value: string. Must be a valid value for setting a margin in CSS. This value is used determine the margin around the "Listen" button.

controlPanelEnabled

Value: string. Setting value to false results in the control panel not appearing once the "Listen" button is clicked. Audio can only be controlled through playing or pausing using the "Listen" button.

controlPanelShadowColor

Value: string. Must be a valid hex color with a value between #000000 and #ffffff. This value is used determine the color of the shadow the control panel has. Only applicable if control panel is enabled.

controlPanelBackgroundColor

Value: string. Must be a valid hex color with a value between #000000 and #ffffff. This value is used determine the background color of the control panel. Only applicable if control panel is enabled.

controlPanelForegroundColor

Value: string. Must be a valid hex color with a value between #000000 and #ffffff. This value is used determine the color of text and icons that appear on the control panel. Only applicable if control panel is enabled.

textHighlightDelay

Value: number. This value determines the delay after which a word is highlighted when reading the text. The number provided indicates the delay in seconds and negative or positive values can be used. Only applicable if text highlighting is enabled.

textHighlightPrimaryColor

Value: string. Must be a valid hex color with a value between #00000000 and #ffffffff. Default is transparent gray: #00000016. Transparency is supported. This value determines the background color of the first highlighted word. Only applicable if text highlighting is enabled.

textHighlightSecondaryColor

Value: string. Must be a valid hex color with a value between #00000000 and #ffffffff. Default is no value. Transparency is supported. This value determines the background color of the two subsequent highlighted words after the first one. Only applicable if text highlighting is enabled.

shareButtonEnabled

Value: boolean. Setting this value to true means that on supported browsers a share button appears on the control panel. Clicking this button allows the end user to share this article using the sharing API that is built-in on their device. Disabling this setting causes this button not to appear.

useLocalStorageForSpeedSelector

Value: boolean. Setting this value to true means that the user preference for selecting a playback speed is stored in browser localStorage. This is classified as a personalization cookie and should be treated as such in your cookie notice if your local jurisdiction requires one.

excludeText

The value for this setting is an object with the following keys: id, className, tagName, elementTextContent and singleWords. Each key must have an array of strings or an empty array as a value. Content matching these id's, classes, tags or text will not be read. Field 'elementTextContent' will match whole strings in an element.