easyaudio_utils 0.2.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec93967424ff134b560c8c8a12db31f2c6082750ed0dd9a57f1c9426639fc582
4
- data.tar.gz: 75a47e89d58d03c76db37aa040eb368fc9b40d99685b14e4ae5f4699bbfa90ff
3
+ metadata.gz: 2db36bcf3b91cd313debbd7f100e00ab90e616b3aa96fc40c62bbc29cf62e92f
4
+ data.tar.gz: 812c13474110e1e5e0c36858a7a714d15aede16c343d57a919112110c1d444d4
5
5
  SHA512:
6
- metadata.gz: cd31e92d0c190ba80c739afea6453f43590c9b08e91163907c22542b53ef803f4469646819fb08c2bd37a9b9f380a490413420574daefafaf0c682a4a35afa17
7
- data.tar.gz: c55becbdfbf3b788a60234f1833d5285d5cd6b11b1b4c2e21d3221c204e183a11341edbb1fe3efcf726f0389ff8d7bf4e45637e3eec06744c2299062e94c4570
6
+ metadata.gz: 628009f593d4a04d1443a11b66d811db1cdc29e6f15fcff306c92cc7e02453c19928acbbe3336da81e124a8cd094f5c10d10b027fb4fd112131ba38b2a1c1629
7
+ data.tar.gz: 2a6368bdb9e99b5b05c916349a8c27b992ed959bc465fb507e84167d72269d08d55bee67a3dfc5dfecd25a44ef2be06c34c11e42d3712f43b3162ccc9a31d9a8
checksums.yaml.gz.sig CHANGED
Binary file
@@ -3,20 +3,24 @@
3
3
  # file: easyaudio_utils.rb
4
4
 
5
5
  require 'wavtool'
6
+ require 'ogginfo'
6
7
 
7
8
  # requirements:
8
- # `apt-get install mplayer sox vorbis-tools
9
+ # `apt-get install mplayer sox vorbis-tools ffmpeg
9
10
 
10
11
  # installing youtube-dl:
11
- #
12
+ #
12
13
  # `sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/bin/youtube-dl`
13
14
  #
14
15
  # `sudo chmod a+rx /usr/bin/youtube-dl`
16
+ #
17
+ # note: avconv is included with ffmpeg
18
+ #
15
19
 
16
20
 
17
21
  module CommandHelper
18
22
  using ColouredText
19
-
23
+
20
24
  def list(a=@commands)
21
25
 
22
26
  format_command = ->(s) do
@@ -43,16 +47,18 @@ class EasyAudioUtils
43
47
  * capture # records audio in FLAC format
44
48
  * concat_files # stiches wav files together
45
49
  * convert # converts a file from 1 format to another #wav #ogg
46
- * duration # return the duration for a wav or ogg
50
+ * cut # cuts the audio into a new file as defined by start time and duration
51
+ * duration # return the duration for a wav or ogg
47
52
  * generate_silence # generates silence in a wav file
48
53
  * play # plays using mplayer
49
54
  * record # alias for capture_desktop
50
55
  * split # split the wav file by silence
56
+ * volume # increase or decrease (0.50 is equal to 50%)
51
57
  * youtube_dl # downloads audio in Ogg (opus) format
52
58
  ".strip.lines.map {|x| x[/(?<=\* ).*/]}.sort
53
59
 
54
60
 
55
- def initialize(audio_in=nil, audio_out='audio.wav', out: audio_out,
61
+ def initialize(audio_in=nil, audio_out='audio.wav', out: audio_out,
56
62
  working_dir: '/tmp')
57
63
 
58
64
  @file_in, @file_out, @working_dir = audio_in, out, working_dir
@@ -64,89 +70,114 @@ class EasyAudioUtils
64
70
  #
65
71
  def capture(show: false)
66
72
 
67
- command = "rec -c 1 -r 8000 -t alsa default #{@file_out} " +
73
+ command = "rec -c 1 -r 8000 -t alsa default #{@file_out} " +
68
74
  "silence 1 0.1 5% 5 1.0 5%"
69
75
  run command, show
70
76
 
71
77
  end
72
-
73
- def concat_files(files=[])
74
- WavTool.new(out: @file_out, ).concat files
78
+
79
+ def concat_files(files=[], sample_rate: nil)
80
+ WavTool.new(out: @file_out, sample_rate: sample_rate).concat files
75
81
  end
76
-
82
+
77
83
  alias concat concat_files
78
-
84
+
85
+ # convert either wav to ogg or ogg to wav
86
+ #
79
87
  def convert()
80
-
88
+
81
89
  if File.extname(@file_in) == '.ogg' then
82
- ogg_to_wav() if File.extname(@file_out) == '.wav'
90
+ ogg_to_wav() if File.extname(@file_out) == '.wav'
91
+ else
92
+ wav_to_ogg() if File.extname(@file_out) == '.ogg'
83
93
  end
84
-
94
+
95
+ end
96
+
97
+ # cut a section of audio and save it to file
98
+ #
99
+ def cut(starttime, duration)
100
+
101
+ command = "avconv -i %s -ss %s -t %s %s" % \
102
+ [@file_in, starttime, duration, @file_out]
103
+ run command, show
104
+
85
105
  end
86
-
106
+
87
107
  def duration()
88
-
108
+
89
109
  case File.extname(@file_in)
90
110
  when '.ogg'
91
- OggInfo.open(@file_in).length.to_i
111
+ OggInfo.open(@file_in).length
92
112
  when '.wav'
93
113
  WavTool.new().duration(@file_in)
94
114
  when '.mp3'
95
- Mp3Info.new(@file_in).length.to_i
96
- end
97
-
115
+ Mp3Info.new(@file_in).length
116
+ end
117
+
98
118
  end
99
-
119
+
100
120
  # silence duration in seconds
101
121
  #
102
122
  def generate_silence(duration)
103
- WavTool.new(out: @out_file).silence duration: duration
123
+ WavTool.new(out: @file_out).silence duration: duration
104
124
  end
105
-
125
+
106
126
  alias record capture
107
-
127
+
108
128
  def play(show: false)
109
129
  command = "mplayer #{@file_out}"
110
130
  run command, show
111
131
  end
112
-
132
+
113
133
  # split by silence
114
134
  #
115
- def split(show: false)
135
+ def split(show: false)
116
136
  command = "sox -V3 #{@file_in} #{@file_out} silence -l 0 " +
117
137
  " 1 0.5 0.1% : newfile : restart"
118
138
  run command, show
119
139
  end
120
-
140
+
141
+ # volume increase or decrease
142
+ #
143
+ def volume(amount=1.0, show: false)
144
+ command = "sox -v #{amount} #{@file_in} #{@file_out}"
145
+ run command, show
146
+ end
147
+
121
148
  # Download and extract audio from a video on YouTube
122
149
  #
123
150
  # By default, Youtube-dl will save the audio in Ogg (opus) format.
124
151
  #
125
- def youtube_dl(show: false)
126
-
152
+ def youtube_dl(show: false)
153
+
127
154
  command = "youtube-dl -x #{url=@file_in}"
128
155
  command += ' -o ' + @file_out if @file_out
129
- run command, show
156
+ run command, show
130
157
 
131
- end
158
+ end
132
159
 
133
160
 
134
161
  private
135
-
136
-
162
+
163
+
137
164
  def ogg_to_wav()
138
- `oggdec #{@file_in} #{@file_out}`
139
- end
165
+ `oggdec #{@file_in} -o #{@file_out}`
166
+ end
167
+
168
+ def wav_to_ogg()
169
+ `sox -V #{@file_in} #{@file_out}`
170
+ end
140
171
 
141
172
  def run(command, show=false)
142
173
 
143
- if show then
174
+ if show then
144
175
  command
145
176
  else
146
177
  puts "Using ->" + command
147
178
  system command
148
179
  end
149
180
 
150
- end
181
+ end
151
182
 
152
183
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easyaudio_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,73 +10,74 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwODE3MTQzMTQ2WhcN
15
- MjEwODE3MTQzMTQ2WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCq7nTP
17
- G87Bg1OlQZHqvE1AEeCfy98/usWtn1+CgLWrqoOIY7VGs8Uk92XOKhMKQeew2uhg
18
- 2ci7aoZZfBVCvLLYM+OD8hNs3kIhR+Ouy5N1eoYFCF6OYMKD9LGAH+cBqH6b76Yn
19
- Kci6XhBNY+aQh56BRNH7FLZ+pcV0/ULvO4sVDqEfht3p/4WceFGnL44FsFDhzCPJ
20
- YQ+KLjWxAI8QuLTLZFGcrZf7/bOq3cy/VEFMUilQ+dOkLMcICfm3WjiN3ZKrnr47
21
- ZQxeTuJWaBsjWk28E7kVssCO0shoYxwBsY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qGSIb3DQEBCwUAA4IBgQAyu6jZ1/IIGGlDiGZkq/Jg+85ql4oL
30
+ qGIk5oAk3R7UA5uHUquZTS6cIZmveNC7jxOpmF0UWDk02qCEp4vRF6WqlcILiRo9
31
+ v3DrgBIwcqbXtmK5DSpABzPSHQe0rCtLwCJ4JdXgTuo7oFjZT2vooZw8xYvLBzQO
32
+ QbNYfvo0f/hiC33cgQRGzvdjUxXfUrAVfYGQ4ojidfoSEwRqbOk5ZKAc+VFp1Z+t
33
+ iGG8j7K5IxgKs/AMr58nOTmBhzi/s5l4d/b0Xpfzl6MZ8dvb3mcERlY9An5OinOL
34
+ 23PTux9AbbfhpMICrfC+LiXbpSDXnitszninLiw4xXoGuqhCtYBfgyYVih8hWD4I
35
+ vu0cR2nfbXRVexqRSfFr1v8temeuL9ruS53Y2+I0erFTUwGux8iL8RuyDZ6v44NE
36
+ F3apwi0l6qdwAskTEyAeMXR7LY7B6wFhidkOS3+jnhOZp9HJZ+YtpDLMYYPDndKG
37
+ 3I3tmYQyMHrny9W25zsC7d5azh5HCfjexAo=
37
38
  -----END CERTIFICATE-----
38
- date: 2020-08-17 00:00:00.000000000 Z
39
+ date: 2022-07-15 00:00:00.000000000 Z
39
40
  dependencies:
40
41
  - !ruby/object:Gem::Dependency
41
42
  name: c32
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.2.0
47
45
  - - "~>"
48
46
  - !ruby/object:Gem::Version
49
- version: '0.2'
47
+ version: '0.3'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 0.3.0
50
51
  type: :runtime
51
52
  prerelease: false
52
53
  version_requirements: !ruby/object:Gem::Requirement
53
54
  requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 0.2.0
57
55
  - - "~>"
58
56
  - !ruby/object:Gem::Version
59
- version: '0.2'
57
+ version: '0.3'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.3.0
60
61
  - !ruby/object:Gem::Dependency
61
62
  name: wavtool
62
63
  requirement: !ruby/object:Gem::Requirement
63
64
  requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 0.1.0
67
65
  - - "~>"
68
66
  - !ruby/object:Gem::Version
69
67
  version: '0.1'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 0.1.0
70
71
  type: :runtime
71
72
  prerelease: false
72
73
  version_requirements: !ruby/object:Gem::Requirement
73
74
  requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: 0.1.0
77
75
  - - "~>"
78
76
  - !ruby/object:Gem::Version
79
77
  version: '0.1'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 0.1.0
80
81
  - !ruby/object:Gem::Dependency
81
82
  name: ruby-mp3info
82
83
  requirement: !ruby/object:Gem::Requirement
@@ -97,8 +98,28 @@ dependencies:
97
98
  - - ">="
98
99
  - !ruby/object:Gem::Version
99
100
  version: 0.8.10
101
+ - !ruby/object:Gem::Dependency
102
+ name: ruby-ogginfo
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '0.7'
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.7.2
111
+ type: :runtime
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.7'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 0.7.2
100
121
  description:
101
- email: james@jamesrobertson.eu
122
+ email: digital.robertson@gmail.com
102
123
  executables: []
103
124
  extensions: []
104
125
  extra_rdoc_files: []
@@ -123,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
144
  - !ruby/object:Gem::Version
124
145
  version: '0'
125
146
  requirements: []
126
- rubygems_version: 3.0.3
147
+ rubygems_version: 3.3.7
127
148
  signing_key:
128
149
  specification_version: 4
129
150
  summary: A wrapper for various command-line audio utilities under GNU/Linux.
metadata.gz.sig CHANGED
Binary file