.. _Usecases:
Use-cases
=========
Open captions driven by REST API calls
--------------------------------------
On Linux operating systems Wowza installation ships with OpenJDK that does not include fonts. On Linux
you need to manually install `fontmanager` and at least one font `openttf-dejavu` to make open captions work.
.. code-block:: bash
    sudo apt-get install fontconfig
    sudo apt-get install ttf-dejavu
To get the REST API up and running, you need to add the below HTTP provider to your ``VHost.xml`` file:
.. code-block:: xml
    
        com.raskenlund.caption.HttpProviderCaptionApi
        captions*
        none
    
You need to add ``ModuleLiveOpenCaptions`` module to your ``Application.xml``
.. code-block:: xml
    
        ...
        
            ModuleLiveOpenCaptions
            ModuleLiveOpenCaptions
            com.raskenlund.caption.ModuleLiveOpenCaptions
        
    
You have to enable transcoder in the application via the Engine Manager UI or directly in the xml:
.. code-block:: xml
    
        
        transcoder
You also need to set the ``raskenlund.804.license`` application property:
.. code-block:: xml
    
        raskenlund.804.license
        W804-1038-xxxx-xxxx-xxxx
        String
    
Assuming your application is called ``live`` and your incoming stream is called ``myStream``, you can
trigger a test caption using curl:
.. code-block:: bash
    curl --location --request POST "http://localhost:1935/captions/v1/applications/live/streams/myStream/caption"
    \ --header "Content-Type: application/json" --data-raw "{
    \"captions\": [
        {
            \"textData\": \"Hello World, this is the captioning module\",
            \"language\": \"en\"
        }
    ],
    \"delay\": 0
    \}"
CEA608 captions driven by REST API calls
----------------------------------------
To get the REST API up and running, you need to add the below HTTP provider to your ``VHost.xml`` file:
.. code-block:: xml
    
        com.raskenlund.caption.HttpProviderCaptionApi
        captions*
        none
    
You need to add ``ModuleOnTextDataToCEA608`` module to your ``Application.xml``
.. code-block:: xml
    
        ModuleOnTextDataToCEA608
        ModuleOnTextDataToCEA608
        com.raskenlund.caption.ModuleOnTextDataToCEA608
    
You need to set the ``raskenlund.804.license`` application property:
.. code-block:: xml
    
        raskenlund.804.license
        W804-1038-xxxx-xxxx-xxxx
        String
    
You need to configure the below timed text settings in the application:
.. code-block:: xml
    
        
        
        
            
                captionLiveIngestType
                onTextData
                String
            
            
                captionLiveIngestLanguages
                eng,nld,nor,hun
                String
            
        
    
WebVTT captions driven by REST API calls
----------------------------------------
Please follow the setup for the CEA608 captions, except that you should not add ``ModuleOnTextDataToCEA608``
to the application, but configure the below timed text property instead:
.. code-block:: xml
    
        
        
        
            
                cupertinoLiveCaptionsUseWebVTT
                true
                Boolean
            
Speech To Text with AWS Transcribe
----------------------------------
You need to add ``ModuleLiveTranscribe`` module to your ``Application.xml``
.. code-block:: xml
    
        ModuleLiveTranscribe
        ModuleLiveTranscribe
        com.raskenlund.caption.ModuleLiveTranscribe
    
And you must enable transcoder in the application via the Engine Manager UI or directly in the xml. If you
do not need video transcoding, you can use the "audioonly" template so that video transcoding is disabled:
.. code-block:: xml
    
        
        transcoder
        audioonly.xml