speech_to_text 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bca24182969a7b66f5772ea1eb348b8989a3c7408c72078f8492d8ea4614fc88
4
- data.tar.gz: b1c03a1c9ec39c3b35174d6effb557fdd0d77a58bb94d2e7474d3a6f044c6550
3
+ metadata.gz: 0601f9186723489cc821a5afe961b94925734a73586f134b43cd8c28ce6c4e68
4
+ data.tar.gz: 7f7fd338e9255e5357a6f6a684131559b386f8377617f33ede8c1b90c8d777de
5
5
  SHA512:
6
- metadata.gz: c583b7ae78b013a4a1bbb219e103527235a53c4ce3cebac78e210fe6c56d248803679d01819950e26abf4cf625f3ed4d7a10acf71cf034281f541b84feae2f50
7
- data.tar.gz: 32da4391b696d236e536a3950b920e756de59cb95e10ba1f5b4444f379dab40f6190398ee7d7e58593974638aadc57d537039bbe3b74f6578269fe3aad52f312
6
+ metadata.gz: e1f01caf754a1a015c7c82a2d8bf0e3112a7224859cbbf527d977a84cfc60b407cb9708cc756d63ebc175650282c64fb2f10c1de878aa7c38973dc392e492263
7
+ data.tar.gz: 3a9ddd6b49011df32d52d50b4f3c83b48c78e11b3e0fac458cb1e75231769e86fa1b4600735cd56d1bd8676b1987f4a605aa936dfc2832af5288d49d5c92f7cd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- speech_to_text (0.1.3)
4
+ speech_to_text (0.1.4)
5
5
  google-cloud-speech (= 0.35.0)
6
6
  google-cloud-storage (= 1.18.2)
7
7
  ibm_watson (~> 0.18.2)
data/README.md CHANGED
@@ -148,7 +148,7 @@ once you get the myarray, you can execute command to create vtt file
148
148
  vtt_file_path = "/home/bbb"
149
149
  vtt_file_name = "vttfile.vtt"
150
150
 
151
- SpeechToText::Util.write_to_webvtt(vtt_file_path,vtt_file_name,myarray)
151
+ SpeechToText::Util.write_to_webvtt(vtt_file_path: "vtt_file_path", vtt_file_name: "vtt_file_name", myarray: myarray, start_time: "5")
152
152
  ```
153
153
 
154
154
  NOTE: if you choose 3playmedia then you don't need to create myarray, you will directly get the vtt file
data/abc.mp3 ADDED
Binary file
@@ -36,8 +36,10 @@ module SpeechToText
36
36
  # rubocop:disable Metrics/MethodLength
37
37
  def self.write_to_webvtt(vtt_file_path:, # rubocop:disable Metrics/AbcSize
38
38
  vtt_file_name:,
39
- myarray:)
39
+ myarray:,
40
+ start_time:)
40
41
 
42
+ start_time = start_time.to_i
41
43
  filename = "#{vtt_file_path}/#{vtt_file_name}"
42
44
  file = File.open(filename, 'w')
43
45
  file.puts "WEBVTT\n\n"
@@ -47,12 +49,12 @@ module SpeechToText
47
49
 
48
50
  file.puts i / 30 + 1
49
51
  if i + 28 < myarray.length
50
- file.puts "#{seconds_to_timestamp myarray[i]} --> #{seconds_to_timestamp myarray[i + 28]}"
52
+ file.puts "#{seconds_to_timestamp (myarray[i] + start_time).to_i} --> #{seconds_to_timestamp (myarray[i + 28] + start_time).to_i}"
51
53
  file.puts "#{myarray[i + 2]} #{myarray[i + 5]} #{myarray[i + 8]} #{myarray[i + 11]} #{myarray[i + 14]}"
52
54
  file.puts "#{myarray[i + 17]} #{myarray[i + 20]} #{myarray[i + 23]} #{myarray[i + 26]} #{myarray[i + 29]}\n\n"
53
55
  else
54
56
  remainder = myarray.length - i
55
- file.puts "#{seconds_to_timestamp myarray[i]} --> #{seconds_to_timestamp myarray[myarray.length - 2]}"
57
+ file.puts "#{seconds_to_timestamp (myarray[i] + start_time).to_i} --> #{seconds_to_timestamp (myarray[myarray.length - 2] + start_time).to_i}"
56
58
  count = 0
57
59
  flag = true
58
60
  while count < remainder
@@ -120,15 +122,19 @@ module SpeechToText
120
122
  audio_content_type:,
121
123
  **duration)
122
124
  # rubocop:enable Metrics/ParameterLists
125
+
123
126
  if duration.empty?
124
127
  video_to_audio_command = "ffmpeg -y -i #{video_file_path}/#{video_name}.#{video_content_type} -ac 1 -ar 16000 #{audio_file_path}/#{audio_name}.#{audio_content_type}"
125
128
  system(video_to_audio_command.to_s)
126
- elsif duration.length == 1
127
- video_to_audio_command = "ffmpeg -y -ss #{0.to_i} -i #{video_file_path}/#{video_name}.#{video_content_type} -t #{duration.values[0]} -ac 1 -ar 16000 #{audio_file_path}/#{audio_name}.#{audio_content_type}"
128
- system(video_to_audio_command.to_s)
129
- else
130
- video_to_audio_command = "ffmpeg -y -ss #{duration.values[0]} -i #{video_file_path}/#{video_name}.#{video_content_type} -t #{duration.values[1]} -ac 1 -ar 16000 #{audio_file_path}/#{audio_name}.#{audio_content_type}"
131
- system(video_to_audio_command.to_s)
129
+ elsif duration[:start_time].nil? && duration[:end_time] != nil
130
+ video_to_audio_command = "ffmpeg -y -ss #{0.to_i} -i #{video_file_path}/#{video_name}.#{video_content_type} -t #{duration[:end_time]} -ac 1 -ar 16000 #{audio_file_path}/#{audio_name}.#{audio_content_type}"
131
+ system(video_to_audio_command.to_s)
132
+ elsif duration[:end_time].nil? && duration[:start_time] != nil
133
+ video_to_audio_command = "ffmpeg -y -ss #{duration[:start_time]} -i #{video_file_path}/#{video_name}.#{video_content_type} -ac 1 -ar 16000 #{audio_file_path}/#{audio_name}.#{audio_content_type}"
134
+ system(video_to_audio_command.to_s)
135
+ else
136
+ video_to_audio_command = "ffmpeg -y -ss #{duration[:start_time]} -i #{video_file_path}/#{video_name}.#{video_content_type} -to #{duration[:end_time]} -ac 1 -ar 16000 #{audio_file_path}/#{audio_name}.#{audio_content_type}"
137
+ system(video_to_audio_command.to_s)
132
138
  end
133
139
 
134
140
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SpeechToText
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
data/webcams.webm ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speech_to_text
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Alam
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2019-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,7 @@ files:
94
94
  - LICENSE.txt
95
95
  - README.md
96
96
  - Rakefile
97
+ - abc.mp3
97
98
  - bin/console
98
99
  - bin/setup
99
100
  - examples/3playmedia.rb
@@ -112,6 +113,7 @@ files:
112
113
  - resources/test/test.json
113
114
  - resources/test/video/video.mp4
114
115
  - speech_to_text.gemspec
116
+ - webcams.webm
115
117
  homepage: https://github.com/bigbluebutton/speech_to_text
116
118
  licenses:
117
119
  - MIT