Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Standalone #24

Merged
merged 5 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 9 additions & 29 deletions DEPLOY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ touch authorized_keys
paste your public key in this file(authorized_keys)
```


# Now install big blue button

(Make sure you are root)

Give access to texttrack to needed folders
```
sudo chmod g+wx /var/bigbluebutton/captions
```

# Now install big blue button

Go home by typing cd and hitting enter, then enter the following command
Expand All @@ -61,7 +51,7 @@ Add texttrack user to bigbluebutton group
```
cat /etc/group (check groups)
sudo usermod -a -G bigbluebutton texttrack
sudo usermod -a -G texttrack bigbluebutton
sudo usermod -a -G texttrack bigbluebutton #######################
```

Give access to texttrack to needed folders
Expand All @@ -75,7 +65,7 @@ Create temp folder for storage at /var/texttrackservice and give permissions
cd /var
sudo mkdir texttrackservice
sudo chown -R texttrack:texttrack /var/texttrackservice (change ownership to texttrackservice)
sudo chmod g+w /var/texttrackservice/ (give group permissions)
sudo chmod g+w /var/texttrackservice/ (give group permissions) ###################
```

# Install text-track-service rails app
Expand Down Expand Up @@ -135,7 +125,7 @@ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
sudo apt-get install -y libssl-dev libreadline-dev
rbenv install 2.5.3
sudo chown -R texttrack.texttrack ~/.rbenv
rbenv local 2.5.3
rbenv local 2.5.3 ######################### rbenv global 2.5.3
ruby -v

gem install bundler
Expand Down Expand Up @@ -204,7 +194,7 @@ cd /usr/local/text-track-service/service/
sudo cp *.service /etc/systemd/system
```

# Start all services
# Start all services (make sure faktory password in the files is correct)
```
sudo systemctl enable text-track-rails
sudo systemctl start text-track-rails
Expand Down Expand Up @@ -250,25 +240,15 @@ sudo journalctl --vacuum-time=1s
Navigate to /usr/local/bigbluebutton/core/scripts/post_publish

sudo gem install rest-client
sudo mv post_publish.rb.example post_publish.rb
sudo nano post_publish.rb

add the following code just above exit 0 at the bottom
require "rest-client"
sudo cp /usr/local/text-track-service/post_publish.rb /usr/local/bigbluebutton/core/scripts/post_publish

response = RestClient::Request.execute(
method: :get,
url: "http://localhost:4000/caption/#{meeting_id}/en-US",
)

if(response.code != 200)
BigBlueButton.logger.info("#{response.code} error")
end

ctrl x type y and hit enter to save and exit
now do bbb-conf secret to find your secret
copy that value into /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml as shared_secret: whatever_your_secret_is

```

#

# If you make any changes to the code please run & keep code clean with Rubocop
```
rubocop --safe-auto-correct --disable-uncorrectable
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ DEPENDENCIES
tzinfo-data

RUBY VERSION
ruby 2.5.3p105
ruby 2.6.3p62

BUNDLED WITH
2.0.2
4 changes: 4 additions & 0 deletions app/controllers/captions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ def caption_recording
record_id = params[:record_id]
caption_locale = params[:caption_locale]
provider = params[:provider]
site = params["site"]
secret = params["secret"]

puts "site -----------#{site}"
puts "secret = #{secret}..................."
# Need to find how to get the key from settings.yaml
# props = YAML::load(File.open('settings.yaml'))
# provider = props["default_provider"]
Expand Down
32 changes: 22 additions & 10 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# frozen_string_literal: true
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20_190_709_150_627) do
create_table 'captions', force: :cascade do |t|
t.string 'record_id'
t.string 'service'
t.string 'status'
t.string 'caption_locale'
t.string 'error'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
ActiveRecord::Schema.define(version: 2019_07_09_150627) do

create_table "captions", force: :cascade do |t|
t.string "record_id"
t.string "service"
t.string "status"
t.string "caption_locale"
t.string "error"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

end
2 changes: 1 addition & 1 deletion development/start-service.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
FAKTORY_PROVIDER=FAKTORY_URL FAKTORY_URL=tcp://:dcd1b7351070d689@localhost:7419 bundle exec ruby ./text-track-service.rb
FAKTORY_PROVIDER=FAKTORY_URL FAKTORY_URL=tcp://:64922309996db536@localhost:7419 bundle exec ruby ./text-track-service.rb
2 changes: 1 addition & 1 deletion development/start-worker.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
FAKTORY_PROVIDER=FAKTORY_URL FAKTORY_URL=tcp://:dcd1b7351070d689@localhost:7419 bundle exec faktory-worker -r ./text-track-worker.rb
FAKTORY_PROVIDER=FAKTORY_URL FAKTORY_URL=tcp://:64922309996db536@localhost:7419 bundle exec faktory-worker -r ./text-track-worker.rb
1 change: 1 addition & 0 deletions lib/texttrack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
require 'texttrack/speechmatics_worker'
require 'texttrack/threeplaymedia_worker'
require 'texttrack/to_audio_worker'
require 'texttrack/util_worker'
require 'texttrack/playback_worker'

module TextTrack # rubocop:disable Style/Documentation
Expand Down
62 changes: 18 additions & 44 deletions lib/texttrack/deepspeech_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,55 +89,29 @@ def perform(params_json, id, job_id, job_name)
SpeechToText::MozillaDeepspeechS2T.order_transcript(job_id,
auth_file_path)

ActiveRecord::Base.connection_pool.with_connection do
u.update(status: "writing subtitle file from #{u.service}")
end

myarray =
SpeechToText::MozillaDeepspeechS2T.create_mozilla_array(callback_json)

current_time = (Time.now.to_f * 1000).to_i

temp_dir = "#{params[:temp_storage]}/#{params[:record_id]}"
temp_track_vtt = "#{params[:record_id]}-#{current_time}-track.vtt"
temp_track_json = "#{params[:record_id]}-#{current_time}-track.json"
inbox = "#{params[:captions_inbox_dir]}/inbox"

SpeechToText::Util.write_to_webvtt(
vtt_file_path: temp_dir.to_s,
vtt_file_name: temp_track_vtt.to_s,
myarray: myarray
)

SpeechToText::Util.recording_json(
file_path: temp_dir.to_s,
record_id: params[:record_id],
timestamp: current_time,
language: params[:caption_locale]
)

ActiveRecord::Base.connection_pool.with_connection do
u.update(status: "done with #{u.service}")
end

File.delete("#{temp_dir}/#{job_name}_jobdetails.json")

FileUtils.mv("#{temp_dir}/#{temp_track_vtt}",
inbox,
verbose: true)
# , :force => true)

FileUtils.mv("#{temp_dir}/#{temp_track_json}",
inbox,
verbose: true)
# , :force => true)

FileUtils.remove_dir(temp_dir.to_s)

TTS::PlaybackWorker.perform_async(params.to_json,
temp_track_vtt,
temp_track_json,
inbox)
data = {
'record_id' => "#{params[:record_id]}",
'temp_dir' => "#{params[:temp_storage]}/#{params[:record_id]}",
'temp_track_vtt' => "#{params[:record_id]}-#{current_time}-track.vtt",
'temp_track_json' => "#{params[:record_id]}-#{current_time}-track.json",
'inbox' => "#{params[:captions_inbox_dir]}/inbox",
'myarray' => myarray,
'current_time' => current_time,
'caption_locale' => "#{params[:caption_locale]}",
'database_id' => "#{id}"
}

TTS::UtilWorker.perform_async(data.to_json)

#TTS::PlaybackWorker.perform_async(params.to_json,
# temp_track_vtt,
# temp_track_json,
# inbox)
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength
Expand Down
69 changes: 19 additions & 50 deletions lib/texttrack/google_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,57 +102,26 @@ def perform(params_json, id, operation_name, audio_type)

callback = SpeechToText::GoogleS2T.get_words(operation_name)
myarray = SpeechToText::GoogleS2T.create_array_google(callback['results'])

ActiveRecord::Base.connection_pool.with_connection do
u.update(status: "writing subtitle file from #{u.service}")
end

current_time = (Time.now.to_f * 1000).to_i

SpeechToText::Util.write_to_webvtt(
vtt_file_path: "#{params[:temp_storage]}/#{params[:record_id]}",
vtt_file_name: "#{params[:record_id]}-#{current_time}-track.vtt",
myarray: myarray
)

SpeechToText::Util.recording_json(
file_path: "#{params[:temp_storage]}/#{params[:record_id]}",
record_id: params[:record_id],
timestamp: current_time,
language: params[:caption_locale]
)

SpeechToText::GoogleS2T.delete_google_storage(
params[:provider][:google_bucket_name],
params[:record_id],
audio_type
)

ActiveRecord::Base.connection_pool.with_connection do
u.update(status: "done with #{u.service}")
end

temp_dir = "#{params[:temp_storage]}/#{params[:record_id]}"
temp_track_vtt = "#{params[:record_id]}-#{current_time}-track.vtt"
temp_track_json = "#{params[:record_id]}-#{current_time}-track.json"
inbox = "#{params[:captions_inbox_dir]}/inbox"

FileUtils.mv("#{temp_dir}/#{temp_track_vtt}",
inbox,
verbose: true)
# , :force => true)

FileUtils.mv("#{temp_dir}/#{temp_track_json}",
inbox,
verbose: true)
# , :force => true)

FileUtils.remove_dir(temp_dir.to_s)

TTS::PlaybackWorker.perform_async(params.to_json,
temp_track_vtt,
temp_track_json,
inbox)

data = {
'record_id' => "#{params[:record_id]}",
'temp_dir' => "#{params[:temp_storage]}/#{params[:record_id]}",
'temp_track_vtt' => "#{params[:record_id]}-#{current_time}-track.vtt",
'temp_track_json' => "#{params[:record_id]}-#{current_time}-track.json",
'inbox' => "#{params[:captions_inbox_dir]}/inbox",
'myarray' => myarray,
'current_time' => current_time,
'caption_locale' => "#{params[:caption_locale]}",
'database_id' => "#{id}"
}

TTS::UtilWorker.perform_async(data.to_json)

# TTS::PlaybackWorker.perform_async(params.to_json,
# temp_track_vtt,
# temp_track_json,
# inbox)
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength
Expand Down
61 changes: 17 additions & 44 deletions lib/texttrack/ibm_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,52 +94,25 @@ def perform(params_json, id, job_id) # rubocop:disable Metrics/AbcSize
# u = nil
myarray =
SpeechToText::IbmWatsonS2T.create_array_watson(callback['results'][0])

ActiveRecord::Base.connection_pool.with_connection do
# u = Caption.find(id)
u.update(status: "writing subtitle file from #{u.service}")
end

current_time = (Time.now.to_f * 1000).to_i

SpeechToText::Util.write_to_webvtt(
vtt_file_path: "#{params[:temp_storage]}/#{params[:record_id]}",
vtt_file_name: "#{params[:record_id]}-#{current_time}-track.vtt",
myarray: myarray
)

SpeechToText::Util.recording_json(
file_path: "#{params[:temp_storage]}/#{params[:record_id]}",
record_id: params[:record_id],
timestamp: current_time,
language: params[:caption_locale]
)

ActiveRecord::Base.connection_pool.with_connection do
u.update(status: "inbox updated with #{u.service}")
end

temp_dir = "#{params[:temp_storage]}/#{params[:record_id]}"
temp_track_vtt = "#{params[:record_id]}-#{current_time}-track.vtt"
temp_track_json = "#{params[:record_id]}-#{current_time}-track.json"
inbox = "#{params[:captions_inbox_dir]}/inbox"

FileUtils.mv("#{temp_dir}/#{temp_track_vtt}",
inbox,
verbose: true)
# , :force => true)

FileUtils.mv("#{temp_dir}/#{temp_track_json}",
inbox,
verbose: true)
# , :force => true)

FileUtils.remove_dir(temp_dir.to_s)

TTS::PlaybackWorker.perform_async(params.to_json,
temp_track_vtt,
temp_track_json,
inbox)
data = {
'record_id' => "#{params[:record_id]}",
'temp_dir' => "#{params[:temp_storage]}/#{params[:record_id]}",
'temp_track_vtt' => "#{params[:record_id]}-#{current_time}-track.vtt",
'temp_track_json' => "#{params[:record_id]}-#{current_time}-track.json",
'inbox' => "#{params[:captions_inbox_dir]}/inbox",
'myarray' => myarray,
'current_time' => current_time,
'caption_locale' => "#{params[:caption_locale]}",
'database_id' => "#{id}"
}

TTS::UtilWorker.perform_async(data.to_json)
#TTS::PlaybackWorker.perform_async(params.to_json,
# temp_track_vtt,
# temp_track_json,
# inbox)
end
# rubocop:enable Metrics/MethodLength
end
Expand Down
Loading