Run Analysis From Lua

CFS provides Lua functions to run media analysis from a Lua script. These functions are named analyze_media_in_document and analyze_media_in_file. There are several advantages to running media analysis from a Lua script, instead of using the MediaServerAnalysis import task.

Firstly, you can use a single configuration to process audio, video, and image files. Your Lua script can identify the type of content that is associated with a document, and choose the correct Media Server engine to use for ingesting that content. The only way to process audio, video, and image files using the MediaServerAnalysis import task is to configure several tasks.

Secondly, you can configure more complex operations. For example, you can write a Lua script that sends audio to Media Server for language identification, and then uses the results of language identification to run speech-to-text with the correct language pack.

Finally, you can run analysis from Lua by configuring a single import task. To use the MediaServerAnalysis import task, you run a Lua script that identifies the documents to process, followed by the MediaServerAnalysis task itself.

CFS is supplied with example scripts that run media analysis. The scripts are in the scripts/mediaserver folder, in the CFS installation directory.

The following procedure demonstrates how to configure media analysis from a Lua script, in this case language detection followed by speech-to-text.

To run media analysis from Lua

  1. Write a Lua script that identifies the documents that you want to process and calls the function analyze_media_in_document (or analyze_media_in_file).

    An example Lua script for running language detection and speech-to-text is located at ./scripts/mediaserver/LangDetectAndSpeechToText.lua.

  2. Create one or more configurations for Media Server that specify the tasks to perform. The Lua script LangDetectAndSpeechToText.lua uses two configurations, one for language detection and another for speech-to-text:

    • ./script_resources/mediaserver/langdetect.cfg
    • ./script_resources/mediaserver/speechtotext.cfg

    If you are using the example configuration files, check that the details are correct for your environment.

  3. In the CFS configuration file, create an import task to run the Lua script. For example:

    [ImportTasks]
    Pre0=Lua:./scripts/mediaserver/LangDetectAndSpeechToText.lua
    
    [MediaServerSettings]
    MediaServerHost=mediaserver:14000
    ReadFromOriginalLocation=true
    // MediaServerSharedPath=<Share Directory UNC path>

    The example script passes the [MediaServerSettings] section to the Lua function analyze_media_in_document. In the example configuration, above, this section provides the host name and ACI port of the Media Server and specifies how Media Server can access the media.

    You can provide files to Media Server in several ways:

    • If your Media Server can read files directly from the CFS working directory, set ReadFromOriginalLocation=TRUE.
    • To copy files to a shared folder, set the configuration parameter MediaServerSharedPath. This folder must be accessible to both CFS and Media Server. CFS copies files to the shared folder so that Media Server can read them. OpenText recommends that you use a shared folder for sending large files.
    • To send files to Media Server using HTTP POST requests, set neither ReadFromOriginalLocation nor MediaServerSharedPath.
  4. Save and close the configuration file.

Examples

The following example configuration runs OCR on all supported image and video files ingested by CFS:

[ImportTasks]
Pre0=Lua:scripts/mediaserver/OCR.lua

[MediaServerSettings]
MediaServerHost=localhost:14000
ReadFromOriginalLocation=TRUE

If your CFS and Media Server are running on separate machines, you can configure CFS to copy the files to a shared folder:

[ImportTasks]
Pre0=Lua:scripts/mediaserver/OCR.lua

[MediaServerSettings]
MediaServerHost=mediaserver:14000
MediaServerSharedPath=\\server\videofiles