Package: tlp-client
tlp-clienttlp-clientis a set of python3 client libraries and tools for thetransLectures Platform (TLP), developed by theMLLP-VRAINresearch group. It can be used to integrate
your media repository's backend with all TLP services, which include automatic
multilingual subtitling, dubbing, and professional post-editing for on-demand
contents.Installationtlp-clientis avalable on PyPI:--$python3-mpipinstalltlp-client# or--$pip3installtlp-clientIt supports Python 3.5+.Librarytlp-clientmodule mainly implements theTLPSpeechClient,TLPTextClientandTLPWebClientclasses that provides
several methods to interact with the/speech,/textand/webAPIs of thetransLectures-UPV Platform.Below are shown some examples on interacting with the/speechAPI. Using this library to query/textand/webAPI interfaces is pretty similar.First, we have to import thetlp_clientlibrary and create aTLPSpeechClientclass instance, using the appropriate argument values. E.g.:>>>importtlp_client>>>tlp=tlp_client.TLPSpeechClient("https://my-tlp-instance.com/api/v3","https://my-tlp-instance.com/player","my-api-user","my-api-key")Toget the list of subtitle languages availablefor a particular Media ID:>>>tlp.api_langs("media-id-1")>>>print(tlp.get_printable_response_data())Todownload a subtitles file, for instance, English subtitles in SRT format:>>>tlp.api_get("media-id-1","en",form="srt")>>>tlp.save_response_data("/path/to/my/media_subs.en.srt")ToGenerate and upload a Media Package Fileto the TLP Server is also quite straightforward:>>># Initialise Manifest, definining media ID:>>>tlp.manifest_init("media-id-2")>>># Add some metadata (media language and title are mandatory)>>>tlp.manifest_set_metadata(language="en",title="Testing tlp_client")>>># Add video/audio file (can be a public URL/URI, also)>>>tlp.manifest_set_main_media_file("/path/to/my/media_file.mp4")>>># Enable Ingest Service's Test Mode, since we are doing a test:>>>tlp.manifest_set_options(test_mode=True)>>># Generate Media Package File and upload it via the /ingest/new interface:>>>tlp.api_ingest_new()>>># Why to print the response? I just want the upload ID!>>>upload_id=tlp.ret_data['id']Totrack the progressof our first upload:>>>tlp.api_status(upload_id)>>>print(tlp.get_printable_response_data())You can build the mostcomplex Media Packagein the world, but only if you want!>>>tlp.manifest_init("media-id-3")>>>tlp.manifest_set_metadata(language="en",title="Really testing tlp_client")>>>tlp.manifest_set_main_media_file("/path/to/my/media_file.mp4")>>># Add a related text file to improve transcription quality>>>tlp.manifest_add_attachment("/path/to/my/doc_file.pdf",tlp_client.TLPClient.FTYPE_CODE_DOCUMENT)>>># Request Spanish subtitles (English are generated by default):>>>tlp.manifest_add_subtitles_request("es")>>># Request also a text-to-speech synthesized Spanish audiotrack:>>>tlp.manifest_add_audiotrack_request("es")>>># ...>>># AND FINALLY...>>>tlp.api_ingest_new()>>># Mere curiosity... print me the generated Manifest JSON object!>>>print(tlp.get_printable_manifest())Extended documentation of this module can be find eitherhereor runninghelp(tlp_client).Forfurther informationyou might check thefull documentation of the transLectures-UPV Platform.Commandline toolstlp-clientcomes with three handy command-line tools that make use of thetlp_clientpython3 module:tlp-api-clitlp-player-urlgentlp-transedit-urlgen.All them require a configuration file (config.ini) to work. By default they
look on the working directory. The --config-fileoption allows to provide it manually. Please note that the--print-sample-config-fileoption can be used to generate a templateconfig.ini` file:--$ tlp-api-cli --print-sample-config-file[general]web_service_url=player_url=translation_editor_url=web_translation_editor_url=[http_auth]enabled=nousername=password=[api_client_auth]enabled=yesusername=secret_key=request_key_expire_lifetime=[player_user_info]user_id=user_full_name=user_confidence=Configuration parameters have to be properly set up,
using your TLP's instance service URLs and API credentials. These can be retrieved from
theAPIsection of your TLP instance's web platform interface (e.g.https://ttp.mllp.upv.es/index.php?page=api).tlp-api-clitlp-api-climakes use of the TLP Python3 Client Library (tlp-client) and implements all TLP API endpoint calls.Examples of use:To upload a new English video file (with ID "my-media-1234") and request English and
Spanish subtitles [/speech/ingest/new API call]:--$tlp-api-clispeechingestnew--language"en"\--title"My first video"\--media-file"/path/to/my/video.mp4"\--requested-languages-subsen\--requested-languages-subses\"my-media-1234"To check the status of an uploaded video, using an upload ID returned by
the /speech/ingest/new interface (i.e. "up-1234") [/speech/status APIcall:--$tlp-api-clispeechstatus"up-1234"To get the subtitle languages available for the video ID "my-media-1234"
[/speech/langs API call]:--$tlp-api-clispeechlangs"my-media-1234"To get English subtitles in SRT format for the video ID "my-media-1234" [/speech/get
API call]:--$tlp-api-clispeechget--format"srt""my-media-1234""en"tlp-player-urlgentlp-player-urlgengenerates valid URLs to call/embed the TLP Player for a media object ID.--$tlp-player-urlgenmy-media-1234tlp-transedit-urlgentlp-transedit-urlgengenerates valid URLs to call/embed the TLP translation editor for a document object ID and translation language.--$tlp-transedit-urlgenmy-document-5678en