easyaudio_utils 0.3.0 → 0.4.1
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 +58 -38
- data.tar.gz.sig +0 -0
- metadata +43 -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: af0fb8aff16634f67b0292615d7f41516fe5fdacef472b2252f515a71fbebad9
|
|
4
|
+
data.tar.gz: ce8e45bbe03e71a65217063f433d18f9483bade9ba72c46e9ff7347b7245feef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 993093aea65b8470910df4ca9a179c32b2f5b47e647088e0d4a5b34c42b8d953d912243be2c1629cdaf6c42d8928fc7d8d9ad006dab3632c56b0c7cd44e969be
|
|
7
|
+
data.tar.gz: c6d02059469db6fe47d1a9a195902e9d13db84e11ac240a5bed3fd393ab984df480b8f1841fdb85a7d7d2e919d8fcdbc7fc030f13e0321da9580f76ddf1a603e
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/easyaudio_utils.rb
CHANGED
|
@@ -9,7 +9,7 @@ require 'ogginfo'
|
|
|
9
9
|
# `apt-get install mplayer sox vorbis-tools ffmpeg
|
|
10
10
|
|
|
11
11
|
# installing youtube-dl:
|
|
12
|
-
#
|
|
12
|
+
#
|
|
13
13
|
# `sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/bin/youtube-dl`
|
|
14
14
|
#
|
|
15
15
|
# `sudo chmod a+rx /usr/bin/youtube-dl`
|
|
@@ -20,7 +20,7 @@ require 'ogginfo'
|
|
|
20
20
|
|
|
21
21
|
module CommandHelper
|
|
22
22
|
using ColouredText
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
def list(a=@commands)
|
|
25
25
|
|
|
26
26
|
format_command = ->(s) do
|
|
@@ -48,16 +48,17 @@ class EasyAudioUtils
|
|
|
48
48
|
* concat_files # stiches wav files together
|
|
49
49
|
* convert # converts a file from 1 format to another #wav #ogg
|
|
50
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
|
|
51
|
+
* duration # return the duration for a wav or ogg
|
|
52
52
|
* generate_silence # generates silence in a wav file
|
|
53
53
|
* play # plays using mplayer
|
|
54
54
|
* record # alias for capture_desktop
|
|
55
55
|
* split # split the wav file by silence
|
|
56
|
+
* volume # increase or decrease (0.50 is equal to 50%)
|
|
56
57
|
* youtube_dl # downloads audio in Ogg (opus) format
|
|
57
58
|
".strip.lines.map {|x| x[/(?<=\* ).*/]}.sort
|
|
58
59
|
|
|
59
60
|
|
|
60
|
-
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,
|
|
61
62
|
working_dir: '/tmp')
|
|
62
63
|
|
|
63
64
|
@file_in, @file_out, @working_dir = audio_in, out, working_dir
|
|
@@ -69,36 +70,44 @@ class EasyAudioUtils
|
|
|
69
70
|
#
|
|
70
71
|
def capture(show: false)
|
|
71
72
|
|
|
72
|
-
command = "rec -c 1 -r 8000 -t alsa default #{@file_out} " +
|
|
73
|
+
command = "rec -c 1 -r 8000 -t alsa default #{@file_out} " +
|
|
73
74
|
"silence 1 0.1 5% 5 1.0 5%"
|
|
74
75
|
run command, show
|
|
75
76
|
|
|
76
77
|
end
|
|
77
|
-
|
|
78
|
-
def concat_files(files=[])
|
|
79
|
-
|
|
78
|
+
|
|
79
|
+
def concat_files(files=[], sample_rate: nil)
|
|
80
|
+
|
|
81
|
+
WavTool.new(out: @file_out, sample_rate: sample_rate,
|
|
82
|
+
src_path: @working_dir).concat files
|
|
80
83
|
end
|
|
81
|
-
|
|
84
|
+
|
|
82
85
|
alias concat concat_files
|
|
83
|
-
|
|
86
|
+
|
|
87
|
+
# convert either wav to ogg or ogg to wav
|
|
88
|
+
#
|
|
84
89
|
def convert()
|
|
85
|
-
|
|
90
|
+
|
|
86
91
|
if File.extname(@file_in) == '.ogg' then
|
|
87
|
-
ogg_to_wav() if File.extname(@file_out) == '.wav'
|
|
92
|
+
ogg_to_wav() if File.extname(@file_out) == '.wav'
|
|
93
|
+
else
|
|
94
|
+
wav_to_ogg() if File.extname(@file_out) == '.ogg'
|
|
88
95
|
end
|
|
89
|
-
|
|
96
|
+
|
|
90
97
|
end
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
|
|
99
|
+
# cut a section of audio and save it to file
|
|
100
|
+
#
|
|
101
|
+
def cut(starttime, duration)
|
|
102
|
+
|
|
94
103
|
command = "avconv -i %s -ss %s -t %s %s" % \
|
|
95
104
|
[@file_in, starttime, duration, @file_out]
|
|
96
|
-
run command, show
|
|
97
|
-
|
|
105
|
+
run command, show
|
|
106
|
+
|
|
98
107
|
end
|
|
99
|
-
|
|
108
|
+
|
|
100
109
|
def duration()
|
|
101
|
-
|
|
110
|
+
|
|
102
111
|
case File.extname(@file_in)
|
|
103
112
|
when '.ogg'
|
|
104
113
|
OggInfo.open(@file_in).length
|
|
@@ -106,60 +115,71 @@ class EasyAudioUtils
|
|
|
106
115
|
WavTool.new().duration(@file_in)
|
|
107
116
|
when '.mp3'
|
|
108
117
|
Mp3Info.new(@file_in).length
|
|
109
|
-
end
|
|
110
|
-
|
|
118
|
+
end
|
|
119
|
+
|
|
111
120
|
end
|
|
112
|
-
|
|
121
|
+
|
|
113
122
|
# silence duration in seconds
|
|
114
123
|
#
|
|
115
124
|
def generate_silence(duration)
|
|
116
125
|
WavTool.new(out: @file_out).silence duration: duration
|
|
117
126
|
end
|
|
118
|
-
|
|
127
|
+
|
|
119
128
|
alias record capture
|
|
120
|
-
|
|
129
|
+
|
|
121
130
|
def play(show: false)
|
|
122
131
|
command = "mplayer #{@file_out}"
|
|
123
132
|
run command, show
|
|
124
133
|
end
|
|
125
|
-
|
|
134
|
+
|
|
126
135
|
# split by silence
|
|
127
136
|
#
|
|
128
|
-
def split(show: false)
|
|
137
|
+
def split(show: false)
|
|
129
138
|
command = "sox -V3 #{@file_in} #{@file_out} silence -l 0 " +
|
|
130
139
|
" 1 0.5 0.1% : newfile : restart"
|
|
131
140
|
run command, show
|
|
132
141
|
end
|
|
133
|
-
|
|
142
|
+
|
|
143
|
+
# volume increase or decrease
|
|
144
|
+
#
|
|
145
|
+
def volume(amount=1.0, show: false)
|
|
146
|
+
command = "sox -v #{amount} #{@file_in} #{@file_out}"
|
|
147
|
+
run command, show
|
|
148
|
+
end
|
|
149
|
+
|
|
134
150
|
# Download and extract audio from a video on YouTube
|
|
135
151
|
#
|
|
136
152
|
# By default, Youtube-dl will save the audio in Ogg (opus) format.
|
|
137
153
|
#
|
|
138
|
-
def youtube_dl(show: false)
|
|
139
|
-
|
|
154
|
+
def youtube_dl(show: false)
|
|
155
|
+
|
|
140
156
|
command = "youtube-dl -x #{url=@file_in}"
|
|
141
157
|
command += ' -o ' + @file_out if @file_out
|
|
142
|
-
run command, show
|
|
158
|
+
run command, show
|
|
143
159
|
|
|
144
|
-
end
|
|
160
|
+
end
|
|
145
161
|
|
|
146
162
|
|
|
147
163
|
private
|
|
148
|
-
|
|
149
|
-
|
|
164
|
+
|
|
165
|
+
|
|
150
166
|
def ogg_to_wav()
|
|
151
|
-
`oggdec #{@file_in} #{@file_out}`
|
|
152
|
-
end
|
|
167
|
+
`oggdec #{@file_in} -o #{@file_out}`
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def wav_to_ogg()
|
|
171
|
+
`sox -V #{@file_in} #{@file_out}`
|
|
172
|
+
end
|
|
153
173
|
|
|
154
174
|
def run(command, show=false)
|
|
155
175
|
|
|
156
|
-
if show then
|
|
176
|
+
if show then
|
|
157
177
|
command
|
|
158
178
|
else
|
|
159
179
|
puts "Using ->" + command
|
|
160
180
|
system command
|
|
161
181
|
end
|
|
162
182
|
|
|
163
|
-
end
|
|
183
|
+
end
|
|
164
184
|
|
|
165
185
|
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.1
|
|
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
|
+
gg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C33cgQRGzvdjUxXfUrAVfYGQ4ojidfoSEwRqbOk5ZKAc+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:
|
|
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
|
|
@@ -118,7 +119,7 @@ dependencies:
|
|
|
118
119
|
- !ruby/object:Gem::Version
|
|
119
120
|
version: 0.7.2
|
|
120
121
|
description:
|
|
121
|
-
email:
|
|
122
|
+
email: digital.robertson@gmail.com
|
|
122
123
|
executables: []
|
|
123
124
|
extensions: []
|
|
124
125
|
extra_rdoc_files: []
|
|
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
143
144
|
- !ruby/object:Gem::Version
|
|
144
145
|
version: '0'
|
|
145
146
|
requirements: []
|
|
146
|
-
rubygems_version: 3.
|
|
147
|
+
rubygems_version: 3.3.7
|
|
147
148
|
signing_key:
|
|
148
149
|
specification_version: 4
|
|
149
150
|
summary: A wrapper for various command-line audio utilities under GNU/Linux.
|
metadata.gz.sig
CHANGED
|
Binary file
|