easyaudio_utils 0.2.3 → 0.4.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/easyaudio_utils.rb +68 -37
- data.tar.gz.sig +0 -0
- metadata +63 -42
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2db36bcf3b91cd313debbd7f100e00ab90e616b3aa96fc40c62bbc29cf62e92f
|
4
|
+
data.tar.gz: 812c13474110e1e5e0c36858a7a714d15aede16c343d57a919112110c1d444d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 628009f593d4a04d1443a11b66d811db1cdc29e6f15fcff306c92cc7e02453c19928acbbe3336da81e124a8cd094f5c10d10b027fb4fd112131ba38b2a1c1629
|
7
|
+
data.tar.gz: 2a6368bdb9e99b5b05c916349a8c27b992ed959bc465fb507e84167d72269d08d55bee67a3dfc5dfecd25a44ef2be06c34c11e42d3712f43b3162ccc9a31d9a8
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/easyaudio_utils.rb
CHANGED
@@ -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
|
-
*
|
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
|
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
|
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: @
|
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.
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
13
|
+
MIIEljCCAv6gAwIBAgIBATANBgkqhkiG9w0BAQsFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTIyMDcxNTA3NTAxNVoXDTIzMDcxNTA3NTAxNVowSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoC
|
18
|
+
ggGBAKRHnQmKwofRlU362PipNPZvEP0C0dxKv3Lf2FRomB9nTCcDAaNbJwmuLCpD
|
19
|
+
/GWAu+2HEbtNY0vlvMoQ0MJ0Zfsih6KdJaNtSuBIxjZMBAdXTQQxNzkV720hpF0o
|
20
|
+
NwoDMoeeHtT9TUjaeF4pKG059H0TuRQUv6fPaihLwBmfPM+6Knzx1aFpJpc+hsXI
|
21
|
+
3RUq2tyP2IlfZitKp7BSMV8mTilaI2W41omh7zxZ0q4kswv2b8yio2fn6m4eMSEy
|
22
|
+
eYCFg3zyy2gb0KTxR/Fzw1fdeeva5pnfDKysUKV4ME863BkAjVDnjGFkasiI9F+l
|
23
|
+
8YOSGwzxAF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ICATE-----
|
38
|
-
date:
|
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.
|
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.
|
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:
|
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.
|
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
|