From 23e656a0083464b7dfdca9ffbddb9903afcc02ea Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Mon, 29 Jul 2019 04:24:32 -0500 Subject: [PATCH 1/8] Add jigasi transcript script --- .gitignore | 0 jigasi.sh | 191 +++++++++++++++++++++++++++++++++++++++ quick_jibri_installer.sh | 15 +++ 3 files changed, 206 insertions(+) create mode 100644 .gitignore create mode 100644 jigasi.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/jigasi.sh b/jigasi.sh new file mode 100644 index 0000000..c54b10c --- /dev/null +++ b/jigasi.sh @@ -0,0 +1,191 @@ +#!/bin/bash +# Quick Jigasi Installer - *buntu 16.04 (LTS) based systems. +# SwITNet Ltd © - 2019, https://switnet.net/ +# GPLv3 or later. + +##################### Whistlist ####################### +# Saves final transcript in translated languages #130 - +# https://github.com/jitsi/jigasi/pull/130 +####################################################### + +clear +echo ' +######################################################################## + Jigasi Transcript addon +######################################################################## + by Software, IT & Networks Ltd +' + +JIGASI_CONFIG=/etc/jitsi/jigasi/config +GC_API_JSON=/opt/gc-sdk/GCTranscriptAPI.json +DOMAIN=$(ls /etc/prosody/conf.d/ | grep -v localhost | awk -F'.cfg' '{print $1}' | awk '!NF || !seen[$0]++') +MEET_CONF=/etc/jitsi/meet/${DOMAIN}-config.js +JIG_SIP_PROP=/etc/jitsi/jigasi/sip-communicator.properties + +export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" +echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list +curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - +apt -y update +apt -y install google-cloud-sdk google-cloud-sdk-app-engine-java + +echo "Please select one of the current options: +[1] I want to configure a new project, service account, billing and JSON credentials. +[2] I already have one project configured and already have a JSON key files from Google" +while [[ $SETUP_TYPE != 1 && $SETUP_TYPE != 2 ]] +do +read -p "What option suits your setup?: (1 or 2)"$'\n' -r SETUP_TYPE +if [ $SETUP_TYPE = 1 ]; then + echo "We'll setup a GC Projects from scratch" +elif [ $SETUP_TYPE = 2 ]; then + echo "We'll setup only the proect and JSON key." +fi +done + +if [ $SETUP_TYPE = 1 ]; then +### Start of new project configuration - Google SDK +#Setup option 1 - Google Cloud SDK +echo "Once logged on Google Cloud SDK, please create a new project (last option)." +gcloud init +read -p "Enter the project name you just created for Jigasi Speech-to-Text"$'\n' -r GC_PROJECT_NAME +#Second login - Google Auth Library +echo "Login to Google Auth Library" +gcloud auth application-default login + +# Start Google Cloud Configuration - Application Service +GC_MEMBER=transcript +echo "Checking if project exist..." +PROJECT_GC_ID=$(gcloud projects list | grep $GC_PROJECT_NAME | awk '{print$3}') +while [ ! -z $PROJECT_GC_ID ] +do +read -p "Enter the project name you just created for Jigasi Speech-to-Text"$'\n' -r GC_PROJECT_NAME +if [ -z PROJECT_GC_ID ] + echo "Please check your project name, + There is no project listed with the provided name: $GC_PROJECT_NAME" + PROJECT_GC_ID=$(gcloud projects list | grep $GC_PROJECT_NAME | awk '{print$3}') +fi + +echo "Your $GC_PROJECT_NAME ID's project is: $PROJECT_GC_ID" + +# Enable Speech2Text +echo "Important: Please enable billing on your project using the following URL: +https://console.developers.google.com/project/$PROJECT_GC_ID/settings" + +echo "Checking billing..." +CHECK_BILLING="$(gcloud services enable speech.googleapis.com 2>/dev/null)" +while [[ $? -eq 1 ]] +do +CHECK_BILLING="$(gcloud services enable speech.googleapis.com 2>/dev/null)" +if [[ $? -eq 1 ]]; then + echo "Seems you haven't enabled billing for this project: $GC_PROJECT_NAME + For that go to: https://console.developers.google.com/project/$PROJECT_GC_ID/settings" + read -p "Press Enter to continue" + CHECK_BILLING="$(gcloud services enable speech.googleapis.com 2>/dev/null)" +fi +done +echo "Billing account seems setup, continuing..." + +gcloud iam service-accounts create $GC_MEMBER + +gcloud projects add-iam-policy-binding $GC_PROJECT_NAME \ + --member serviceAccount:$GC_MEMBER@$GC_PROJECT_NAME.iam.gserviceaccount.com \ + --role roles/editor + +echo "Setup credentials:" +echo "Please go and download your valid json key at: +https://console.developers.google.com/apis/credentials?folder=&organizationId=&project=$GC_PROJECT_NAME" +### End of new project configuration - Google SDK +fi + +if [ $SETUP_TYPE = 2 ]; then +#Setup option 1 - Google Cloud SDK +echo "Once logged on Google Cloud SDK, please select the project that owns to the JSON key." +gcloud init +fi + +echo "Setting up JSON key file..." +sleep 2 +mkdir /opt/gc-sdk/ +cat << KEY_JSON > $GC_API_JSON +# +# Paste below this comment your GC JSON key for the service account: +# $GC_MEMBER@$GC_PROJECT_NAME.iam.gserviceaccount.com +# +# These comment lines will be deleted afterwards. +# +KEY_JSON +chmod 644 $GC_API_JSON +nano $GC_API_JSON +sed -i "1,6d" $GC_API_JSON + +CHECK_JSON_KEY="$(cat $GC_API_JSON | python -m json.tool 2>/dev/null)" +while [[ $? -eq 1 ]] +do +CHECK_JSON_KEY="$(cat $GC_API_JSON | python -m json.tool 2>/dev/null)" +if [[ $? -eq 1 ]]; then + echo "Check again your JSON file, syntax doesn't seem right" + sleep 2 + nano $GC_API_JSON + CHECK_JSON_KEY="$(cat $GC_API_JSON | python -m json.tool 2>/dev/null)" +fi +done +echo "Great, seems now your JSON key syntax is fine." + +export GOOGLE_APPLICATION_CREDENTIALS=$GC_API_JSON + +echo "Installing Jigasi, your SIP credentials will be asked. (skip)" +apt -y install jigasi + + +cat << JIGASI_CONF >> $JIGASI_CONFIG + +GOOGLE_APPLICATION_CREDENTIALS=$GC_API_JSON + +JIGASI_CONF + +echo "Your Google Cloud credentials are at $GC_API_JSON" + +echo "Setting up Jigasi transcript with current platform..." +#Connect callcontrol +sed -i "s|// call_control:|call_control:|" $MEET_CONF + +#siptest2siptest@domain.con +#changed from conference to internal.auth from jibri +sed -i "s|siptest|siptest@internal.auth.$DOMAIN|" $JIG_SIP_PROP + +#Enable transcript / disable sip +sed -i "/ENABLE_TRANSCRIPTION/ s|#||" $JIG_SIP_PROP +sed -i "/ENABLE_TRANSCRIPTION/ s|false|true|" $JIG_SIP_PROP +sed -i "/ENABLE_SIP/ s|#||" $JIG_SIP_PROP +sed -i "/ENABLE_SIP/ s|true|false|" $JIG_SIP_PROP + +#Transcript format +sed -i "/SAVE_JSON/ s|# ||" $JIG_SIP_PROP +sed -i "/SEND_JSON/ s|# ||" $JIG_SIP_PROP +sed -i "/SAVE_TXT/ s|# ||" $JIG_SIP_PROP +sed -i "/SEND_TXT/ s|# ||" $JIG_SIP_PROP +sed -i "/SEND_TXT/ s|false|true|" $JIG_SIP_PROP + +#Remember to study how to use LE or what's needed #ToDo +sed -i "/ALWAYS_TRUST_MODE_ENABLED/ s|# ||" $JIG_SIP_PROP + +#Jigasi credentials +sed -i "/xmpp.acc.USER_ID/ s|# ||" $JIG_SIP_PROP +sed -i "/xmpp.acc.USER_ID/ s|SOME_USER\@SOME_DOMAIN|transcript\@auth.$DOMAIN|" $JIG_SIP_PROP +sed -i "/xmpp.acc.PASS/ s|# ||" $JIG_SIP_PROP +sed -i "/xmpp.acc.PASS/ s|SOME_PASS|jigasi|" $JIG_SIP_PROP +sed -i "/xmpp.acc.ANONYMOUS_AUTH/ s|# ||" $JIG_SIP_PROP + +prosodyctl register transcript auth.$DOMAIN jigasi + +systemctl restart prosody ji* + +echo "To test, you need to enable subtitles beforehand then invite \ +\"jitsi_meet_transcribe\" to the meeting (no quotes)." + +echo "Full transcript files are available at: +--> /var/lib/jigasi/transcripts/" + +echo "Happy transcripting..." + +#APP.conference._room.dial("jitsi_meet_transcribe"); + diff --git a/quick_jibri_installer.sh b/quick_jibri_installer.sh index 4e5d105..3cc1f24 100644 --- a/quick_jibri_installer.sh +++ b/quick_jibri_installer.sh @@ -202,6 +202,16 @@ elif [ $ENABLE_SSL = yes ]; then echo "SSL will be enabled." fi done +#Jigasi +while [[ $ENABLE_TRANSCRIPT != yes && $ENABLE_TRANSCRIPT != no ]] +do +read -p "Do you want to setup Jigasi Transcription: (yes or no)"$'\n' -r ENABLE_TRANSCRIPT +if [ $ENABLE_TRANSCRIPT = no ]; then + echo "Jigasi Transcription won't be enabled." +elif [ $ENABLE_TRANSCRIPT = yes ]; then + echo "Jigasi Transcription will be enabled." +fi +done echo "$JB_AUTH_PASS" > $JB_AUTH_PASS_FILE chmod 600 $JB_AUTH_PASS_FILE @@ -521,6 +531,11 @@ else echo "No webserver found please report." fi +elif [ $ENABLE_TRANSCRIPT = yes ]; then + echo "Jigasi Transcription will be enabled." + bash <(curl -s https://raw.githubusercontent.com/switnet-ltd/quick-jibri-installer/jigasi/jigasi.sh) +fi + echo " ######################################################################## Installation complete!! From 401188d2b1bd3a4c36dc62dbe4e42fc6fb1ca558 Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Mon, 29 Jul 2019 04:30:08 -0500 Subject: [PATCH 2/8] Replace call script --- quick_jibri_installer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick_jibri_installer.sh b/quick_jibri_installer.sh index 3cc1f24..589676e 100644 --- a/quick_jibri_installer.sh +++ b/quick_jibri_installer.sh @@ -533,7 +533,7 @@ fi elif [ $ENABLE_TRANSCRIPT = yes ]; then echo "Jigasi Transcription will be enabled." - bash <(curl -s https://raw.githubusercontent.com/switnet-ltd/quick-jibri-installer/jigasi/jigasi.sh) + bash ./jigasi.sh fi echo " From 6a5e0135ba307572fe335eef350c156ee93cd24e Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Mon, 29 Jul 2019 12:13:41 -0500 Subject: [PATCH 3/8] Fix comments and some issues --- jigasi.sh | 26 +++++++++++++++++--------- quick_jibri_installer.sh | 4 ++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/jigasi.sh b/jigasi.sh index c54b10c..f45bb33 100644 --- a/jigasi.sh +++ b/jigasi.sh @@ -30,7 +30,7 @@ apt -y install google-cloud-sdk google-cloud-sdk-app-engine-java echo "Please select one of the current options: [1] I want to configure a new project, service account, billing and JSON credentials. -[2] I already have one project configured and already have a JSON key files from Google" +[2] I already have one project configured and already have a JSON key file from Google" while [[ $SETUP_TYPE != 1 && $SETUP_TYPE != 2 ]] do read -p "What option suits your setup?: (1 or 2)"$'\n' -r SETUP_TYPE @@ -58,12 +58,12 @@ PROJECT_GC_ID=$(gcloud projects list | grep $GC_PROJECT_NAME | awk '{print$3}') while [ ! -z $PROJECT_GC_ID ] do read -p "Enter the project name you just created for Jigasi Speech-to-Text"$'\n' -r GC_PROJECT_NAME -if [ -z PROJECT_GC_ID ] +if [ -z PROJECT_GC_ID ]; then echo "Please check your project name, There is no project listed with the provided name: $GC_PROJECT_NAME" PROJECT_GC_ID=$(gcloud projects list | grep $GC_PROJECT_NAME | awk '{print$3}') fi - +done echo "Your $GC_PROJECT_NAME ID's project is: $PROJECT_GC_ID" # Enable Speech2Text @@ -128,7 +128,9 @@ if [[ $? -eq 1 ]]; then CHECK_JSON_KEY="$(cat $GC_API_JSON | python -m json.tool 2>/dev/null)" fi done -echo "Great, seems now your JSON key syntax is fine." +echo " +Great, seems your JSON key syntax is fine. +" export GOOGLE_APPLICATION_CREDENTIALS=$GC_API_JSON @@ -179,13 +181,19 @@ prosodyctl register transcript auth.$DOMAIN jigasi systemctl restart prosody ji* -echo "To test, you need to enable subtitles beforehand then invite \ -\"jitsi_meet_transcribe\" to the meeting (no quotes)." +echo " +To test, you need to enable subtitles beforehand then invite \ +\"jitsi_meet_transcribe\" to the meeting (no quotes). +" -echo "Full transcript files are available at: ---> /var/lib/jigasi/transcripts/" +echo " +Full transcript files are available at: +--> /var/lib/jigasi/transcripts/ +" -echo "Happy transcripting..." +echo " +Happy transcripting! +" #APP.conference._room.dial("jitsi_meet_transcribe"); diff --git a/quick_jibri_installer.sh b/quick_jibri_installer.sh index 589676e..1075b98 100644 --- a/quick_jibri_installer.sh +++ b/quick_jibri_installer.sh @@ -531,9 +531,9 @@ else echo "No webserver found please report." fi -elif [ $ENABLE_TRANSCRIPT = yes ]; then +if [ $ENABLE_TRANSCRIPT = yes ]; then echo "Jigasi Transcription will be enabled." - bash ./jigasi.sh + bash $PWD/jigasi.sh fi echo " From e9ca5ad36d3d9b6ea52fc756ccd24bab75f69d9d Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Mon, 29 Jul 2019 12:34:24 -0500 Subject: [PATCH 4/8] Add missing UI button --- jigasi.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jigasi.sh b/jigasi.sh index f45bb33..f1e1116 100644 --- a/jigasi.sh +++ b/jigasi.sh @@ -149,6 +149,8 @@ echo "Your Google Cloud credentials are at $GC_API_JSON" echo "Setting up Jigasi transcript with current platform..." #Connect callcontrol sed -i "s|// call_control:|call_control:|" $MEET_CONF +sed -i "s|// transcribingEnabled|transcribingEnabled|" $MEET_CONF +sed -i "/transcribingEnabled/ s|false|true|" $MEET_CONF #siptest2siptest@domain.con #changed from conference to internal.auth from jibri From 69f956ac64dffa2ecd6de6bc19acfe276d2e4b78 Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Tue, 30 Jul 2019 13:57:41 -0500 Subject: [PATCH 5/8] Check if repository exist --- jigasi.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/jigasi.sh b/jigasi.sh index f1e1116..995d3eb 100644 --- a/jigasi.sh +++ b/jigasi.sh @@ -21,10 +21,25 @@ GC_API_JSON=/opt/gc-sdk/GCTranscriptAPI.json DOMAIN=$(ls /etc/prosody/conf.d/ | grep -v localhost | awk -F'.cfg' '{print $1}' | awk '!NF || !seen[$0]++') MEET_CONF=/etc/jitsi/meet/${DOMAIN}-config.js JIG_SIP_PROP=/etc/jitsi/jigasi/sip-communicator.properties +DIST=$(lsb_release -sc) +CHECK_GC_REPO=$(apt-cache policy | grep http | grep cloud-sdk | head -n1 | awk '{print $3}' | awk -F '/' '{print $1}') -export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" -echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list -curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - +install_gc_repo() { + if [ "$CHECK_GC_REPO" = "cloud-sdk-$DIST" ]; then + echo " +Google Cloud SDK repository already on the system! +" +else + echo " +Adding Google Cloud SDK repository for latest updates +" + export CLOUD_SDK_REPO="cloud-sdk-$DIST" + echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list + curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - + +fi +} +install_gc_repo apt -y update apt -y install google-cloud-sdk google-cloud-sdk-app-engine-java @@ -131,6 +146,7 @@ done echo " Great, seems your JSON key syntax is fine. " +sleep 2 export GOOGLE_APPLICATION_CREDENTIALS=$GC_API_JSON @@ -167,7 +183,7 @@ sed -i "/SAVE_JSON/ s|# ||" $JIG_SIP_PROP sed -i "/SEND_JSON/ s|# ||" $JIG_SIP_PROP sed -i "/SAVE_TXT/ s|# ||" $JIG_SIP_PROP sed -i "/SEND_TXT/ s|# ||" $JIG_SIP_PROP -sed -i "/SEND_TXT/ s|false|true|" $JIG_SIP_PROP +#sed -i "/SEND_TXT/ s|false|true|" $JIG_SIP_PROP #Remember to study how to use LE or what's needed #ToDo sed -i "/ALWAYS_TRUST_MODE_ENABLED/ s|# ||" $JIG_SIP_PROP @@ -198,4 +214,3 @@ Happy transcripting! " #APP.conference._room.dial("jitsi_meet_transcribe"); - From a063669e9c2f9e09b83624c91ef90960c79971fd Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Tue, 30 Jul 2019 15:16:37 -0500 Subject: [PATCH 6/8] Add missing(?) authentication --- jigasi.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jigasi.sh b/jigasi.sh index 995d3eb..5d88e30 100644 --- a/jigasi.sh +++ b/jigasi.sh @@ -115,6 +115,8 @@ if [ $SETUP_TYPE = 2 ]; then #Setup option 1 - Google Cloud SDK echo "Once logged on Google Cloud SDK, please select the project that owns to the JSON key." gcloud init +echo "Login to Google Auth Library" +gcloud auth application-default login fi echo "Setting up JSON key file..." From 99da3272b0113597b3507f8ef0fafc252626cce0 Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Wed, 31 Jul 2019 02:37:12 -0500 Subject: [PATCH 7/8] Fix contidion and format --- jigasi.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jigasi.sh b/jigasi.sh index 5d88e30..d8f6e34 100644 --- a/jigasi.sh +++ b/jigasi.sh @@ -70,7 +70,7 @@ gcloud auth application-default login GC_MEMBER=transcript echo "Checking if project exist..." PROJECT_GC_ID=$(gcloud projects list | grep $GC_PROJECT_NAME | awk '{print$3}') -while [ ! -z $PROJECT_GC_ID ] +while [ -z $PROJECT_GC_ID ] do read -p "Enter the project name you just created for Jigasi Speech-to-Text"$'\n' -r GC_PROJECT_NAME if [ -z PROJECT_GC_ID ]; then @@ -92,7 +92,8 @@ do CHECK_BILLING="$(gcloud services enable speech.googleapis.com 2>/dev/null)" if [[ $? -eq 1 ]]; then echo "Seems you haven't enabled billing for this project: $GC_PROJECT_NAME - For that go to: https://console.developers.google.com/project/$PROJECT_GC_ID/settings" + For that go to: https://console.developers.google.com/project/$PROJECT_GC_ID/settings + " read -p "Press Enter to continue" CHECK_BILLING="$(gcloud services enable speech.googleapis.com 2>/dev/null)" fi @@ -127,12 +128,14 @@ cat << KEY_JSON > $GC_API_JSON # Paste below this comment your GC JSON key for the service account: # $GC_MEMBER@$GC_PROJECT_NAME.iam.gserviceaccount.com # +# Visit the following URL and create a *Service Account Key*: +# https://console.developers.google.com/apis/credentials?folder=&organizationId=&project=$GC_PROJECT_NAME # These comment lines will be deleted afterwards. # KEY_JSON chmod 644 $GC_API_JSON nano $GC_API_JSON -sed -i "1,6d" $GC_API_JSON +sed -i '/^#/d' $GC_API_JSON CHECK_JSON_KEY="$(cat $GC_API_JSON | python -m json.tool 2>/dev/null)" while [[ $? -eq 1 ]] @@ -152,7 +155,7 @@ sleep 2 export GOOGLE_APPLICATION_CREDENTIALS=$GC_API_JSON -echo "Installing Jigasi, your SIP credentials will be asked. (skip)" +echo "Installing Jigasi, your SIP credentials will be asked. (mandatory)" apt -y install jigasi From 58b27bdceebab622ae9d5e377e4b67594bede3ee Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Wed, 31 Jul 2019 02:51:32 -0500 Subject: [PATCH 8/8] Release of Jigasi Transcript --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6ca62c1..4e80c94 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,16 @@ Bash installer for Jibri on *buntu 16.04 LTS based systems * Enabled Jitsi Electron app detection server side. * Standalone SSL Certbot/LE implementation * Option to enable Secure Rooms +* (New) Jigasi Transcript - Speech to Text powered by Google API ## Requirements * Valid domain with DNS already set (preferably). * Minimum recommended for video recording: 4 GB RAM / 4 Cores. * Dropbox developer App key & redirect url configured (if you choose to enable Dropbox upload). * Webcam +### Jigasi Transcript +* SIP account +* Google Cloud Account with Billing setup. ## Custom changes * Welcome page enabled