easyaudio_utils 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/easyaudio_utils.rb +55 -53
- metadata +70 -30
- 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: f50a6a89e8841dc34323a1c21a449400cae0caacb8671328b4bf8b269a4a2a37
|
4
|
+
data.tar.gz: f7bf6bdf7dd187a738916520bdc42dcba2a54be2c3101af89c11000d33598e16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d08657f0b811b0761bf95d8f6d81109a6dbdbb9c370a497dc4770716e91d4694a6e1a4f491d828c44be4977b2a1baf3bdbae035c54a8b5e7defee4896cf2a94
|
7
|
+
data.tar.gz: 7cff7250a5b9b2ff73bd94578d6423e73b6206caa62cd29d26d960770afeac0024e602c6defd81cdf90a0b89e88f4a6c194689a4b28330b58497fea0fb08a026
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/easyaudio_utils.rb
CHANGED
@@ -2,11 +2,20 @@
|
|
2
2
|
|
3
3
|
# file: easyaudio_utils.rb
|
4
4
|
|
5
|
-
require '
|
6
|
-
require '
|
5
|
+
require 'wavtool'
|
6
|
+
require 'ogginfo'
|
7
7
|
|
8
8
|
# requirements:
|
9
|
-
# `apt-get install mplayer sox vorbis-tools
|
9
|
+
# `apt-get install mplayer sox vorbis-tools ffmpeg
|
10
|
+
|
11
|
+
# installing youtube-dl:
|
12
|
+
#
|
13
|
+
# `sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/bin/youtube-dl`
|
14
|
+
#
|
15
|
+
# `sudo chmod a+rx /usr/bin/youtube-dl`
|
16
|
+
#
|
17
|
+
# note: avconv is included with ffmpeg
|
18
|
+
#
|
10
19
|
|
11
20
|
|
12
21
|
module CommandHelper
|
@@ -29,54 +38,22 @@ module CommandHelper
|
|
29
38
|
|
30
39
|
end
|
31
40
|
|
32
|
-
module WavTool
|
33
|
-
include WaveFile
|
34
|
-
|
35
|
-
def wav_silence(filename, duration: 1)
|
36
|
-
|
37
|
-
square_cycle = [0] * 100 * duration
|
38
|
-
buffer = Buffer.new(square_cycle, Format.new(:mono, :float, 44100))
|
39
|
-
|
40
|
-
Writer.new(filename, Format.new(:mono, :pcm_16, 22050)) do |writer|
|
41
|
-
220.times { writer.write(buffer) }
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
def wav_concat(files, save_file='audio.wav')
|
47
|
-
|
48
|
-
Writer.new(save_file, Format.new(:stereo, :pcm_16, 22050)) do |writer|
|
49
|
-
|
50
|
-
files.each do |file_name|
|
51
|
-
|
52
|
-
Reader.new(file_name).each_buffer(samples_per_buffer=4096) do |buffer|
|
53
|
-
writer.write(buffer)
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
def duration(file_name)
|
62
|
-
Reader.new(file_name).total_duration
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
41
|
|
68
42
|
class EasyAudioUtils
|
69
43
|
extend CommandHelper
|
70
|
-
|
44
|
+
|
71
45
|
|
72
46
|
@commands = "
|
73
|
-
*
|
47
|
+
* capture # records audio in FLAC format
|
74
48
|
* concat_files # stiches wav files together
|
75
49
|
* convert # converts a file from 1 format to another #wav #ogg
|
50
|
+
* cut # cuts the audio into a new file as defined by start time and duration
|
76
51
|
* duration # return the duration for a wav or ogg
|
77
52
|
* generate_silence # generates silence in a wav file
|
78
53
|
* play # plays using mplayer
|
79
54
|
* record # alias for capture_desktop
|
55
|
+
* split # split the wav file by silence
|
56
|
+
* youtube_dl # downloads audio in Ogg (opus) format
|
80
57
|
".strip.lines.map {|x| x[/(?<=\* ).*/]}.sort
|
81
58
|
|
82
59
|
|
@@ -90,7 +67,7 @@ class EasyAudioUtils
|
|
90
67
|
# records audio in mono audio
|
91
68
|
# tested with .flac
|
92
69
|
#
|
93
|
-
def capture()
|
70
|
+
def capture(show: false)
|
94
71
|
|
95
72
|
command = "rec -c 1 -r 8000 -t alsa default #{@file_out} " +
|
96
73
|
"silence 1 0.1 5% 5 1.0 5%"
|
@@ -99,7 +76,7 @@ class EasyAudioUtils
|
|
99
76
|
end
|
100
77
|
|
101
78
|
def concat_files(files=[])
|
102
|
-
|
79
|
+
WavTool.new(out: @file_out, ).concat files
|
103
80
|
end
|
104
81
|
|
105
82
|
alias concat concat_files
|
@@ -107,18 +84,28 @@ class EasyAudioUtils
|
|
107
84
|
def convert()
|
108
85
|
|
109
86
|
if File.extname(@file_in) == '.ogg' then
|
110
|
-
|
87
|
+
ogg_to_wav() if File.extname(@file_out) == '.wav'
|
111
88
|
end
|
112
89
|
|
113
90
|
end
|
114
91
|
|
92
|
+
def cut(starttime, duration)
|
93
|
+
|
94
|
+
command = "avconv -i %s -ss %s -t %s %s" % \
|
95
|
+
[@file_in, starttime, duration, @file_out]
|
96
|
+
run command, show
|
97
|
+
|
98
|
+
end
|
99
|
+
|
115
100
|
def duration()
|
116
101
|
|
117
102
|
case File.extname(@file_in)
|
118
103
|
when '.ogg'
|
119
|
-
|
104
|
+
OggInfo.open(@file_in).length
|
120
105
|
when '.wav'
|
121
|
-
|
106
|
+
WavTool.new().duration(@file_in)
|
107
|
+
when '.mp3'
|
108
|
+
Mp3Info.new(@file_in).length
|
122
109
|
end
|
123
110
|
|
124
111
|
end
|
@@ -126,7 +113,7 @@ class EasyAudioUtils
|
|
126
113
|
# silence duration in seconds
|
127
114
|
#
|
128
115
|
def generate_silence(duration)
|
129
|
-
|
116
|
+
WavTool.new(out: @file_out).silence duration: duration
|
130
117
|
end
|
131
118
|
|
132
119
|
alias record capture
|
@@ -135,20 +122,36 @@ class EasyAudioUtils
|
|
135
122
|
command = "mplayer #{@file_out}"
|
136
123
|
run command, show
|
137
124
|
end
|
125
|
+
|
126
|
+
# split by silence
|
127
|
+
#
|
128
|
+
def split(show: false)
|
129
|
+
command = "sox -V3 #{@file_in} #{@file_out} silence -l 0 " +
|
130
|
+
" 1 0.5 0.1% : newfile : restart"
|
131
|
+
run command, show
|
132
|
+
end
|
133
|
+
|
134
|
+
# Download and extract audio from a video on YouTube
|
135
|
+
#
|
136
|
+
# By default, Youtube-dl will save the audio in Ogg (opus) format.
|
137
|
+
#
|
138
|
+
def youtube_dl(show: false)
|
139
|
+
|
140
|
+
command = "youtube-dl -x #{url=@file_in}"
|
141
|
+
command += ' -o ' + @file_out if @file_out
|
142
|
+
run command, show
|
143
|
+
|
144
|
+
end
|
138
145
|
|
139
146
|
|
140
147
|
private
|
141
148
|
|
142
|
-
def ogg_duration()
|
143
|
-
OggInfo.open(@file_in) {|ogg| ogg.length.to_i }
|
144
|
-
end
|
145
149
|
|
146
150
|
def ogg_to_wav()
|
147
151
|
`oggdec #{@file_in} #{@file_out}`
|
148
|
-
end
|
149
|
-
|
152
|
+
end
|
150
153
|
|
151
|
-
def run(command, show
|
154
|
+
def run(command, show=false)
|
152
155
|
|
153
156
|
if show then
|
154
157
|
command
|
@@ -160,4 +163,3 @@ class EasyAudioUtils
|
|
160
163
|
end
|
161
164
|
|
162
165
|
end
|
163
|
-
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,31 +11,31 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADA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bWFzdGVyQGphbWVzcm9iZXJ0
|
27
27
|
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAcHdlP926iCRowPRKfQyDy611G3ceIHe/c7g5Jlov
|
29
|
+
bjYf/072xcxtpEl3gCkiYAg3RJcje7p11M9yvotU+LfaraeNfc4QY3aKCmdeydZb
|
30
|
+
M9Epmnd5PzazZzRfGIpp55/FvZhJ8L/3WbFyttgsB1I98WwMcWN4/Z45DfQPAalR
|
31
|
+
1+dLVo6FqBtCcEKTSi62qFl/Zww5ErCEyqBCeKArZWPDbVfEKqfjzJWiYNwnuJmJ
|
32
|
+
r+zG3ZSNfLpTRj1IU6hXGBXBM0i+nngbppJAcSRHYDYNHkPxBdwHYNwivPGg0/ic
|
33
|
+
Y1Irmj+W7OWcIk289KiEIn9QgHqfL/FkynAa3wW4utEt7evObGIpXJbMDdc55d+b
|
34
|
+
nN9uJYaGOT/Ui5kx/UjoSqzBWOzkdwZOozcrEyqVVoWIghDaevdwC5G0N6sPpIkr
|
35
|
+
iV3Y2C+RMq1lzH37GpnqYY/GbIvXMmQ7PO19tYLBCV/OUawXzR16PkiHVjIGnDyN
|
36
|
+
PaGqcnyxdoovIOkXQxqj5+Zd
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2020-08-27 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: c32
|
@@ -58,25 +58,65 @@ dependencies:
|
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0.2'
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
61
|
+
name: wavtool
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
66
|
+
version: 0.1.0
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '0.1'
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 0.1.0
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: '
|
79
|
+
version: '0.1'
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: ruby-mp3info
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - "~>"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0.8'
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.8.10
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.8'
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.8.10
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: ruby-ogginfo
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - "~>"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0.7'
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.7.2
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0.7'
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 0.7.2
|
80
120
|
description:
|
81
121
|
email: james@jamesrobertson.eu
|
82
122
|
executables: []
|
@@ -103,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
143
|
- !ruby/object:Gem::Version
|
104
144
|
version: '0'
|
105
145
|
requirements: []
|
106
|
-
rubygems_version: 3.0.
|
146
|
+
rubygems_version: 3.0.3
|
107
147
|
signing_key:
|
108
148
|
specification_version: 4
|
109
149
|
summary: A wrapper for various command-line audio utilities under GNU/Linux.
|
metadata.gz.sig
CHANGED
Binary file
|