easyaudio_utils 0.1.0 → 0.2.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.tar.gz.sig +0 -0
- data/lib/easyaudio_utils.rb +22 -52
- metadata +8 -8
- 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: 1a1828884e196a7f7d4f3802dfcd842f65bc5203f4c49f95bbcb284560749173
|
4
|
+
data.tar.gz: ba2b1bb980a725a5d17a42f7ee96b5556b18204d78669206b54262900c58787a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86effae197c629e72435efc917d3263b31f10c92fc5e4dd515632d5f08ef1e4e426776cc2ab2d346343ee30e56687c51a250d181f8cd2c7812fcebbadb01242
|
7
|
+
data.tar.gz: 3a766f5b403498535c6de0360594635d926168fdbce244e945f7cf33c75959954197ed66f7e6ac75b017bb5e007dfd2bb74830c22da8d7c82e4c4a08d1f5f5d5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/easyaudio_utils.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
# file: easyaudio_utils.rb
|
4
4
|
|
5
|
-
require '
|
6
|
-
require 'wavefile'
|
5
|
+
require 'wavtool'
|
7
6
|
|
8
7
|
# requirements:
|
9
8
|
# `apt-get install mplayer sox vorbis-tools
|
@@ -29,54 +28,20 @@ module CommandHelper
|
|
29
28
|
|
30
29
|
end
|
31
30
|
|
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
31
|
|
68
32
|
class EasyAudioUtils
|
69
33
|
extend CommandHelper
|
70
|
-
|
34
|
+
|
71
35
|
|
72
36
|
@commands = "
|
73
|
-
*
|
37
|
+
* capture # records audio in FLAC format
|
74
38
|
* concat_files # stiches wav files together
|
75
39
|
* convert # converts a file from 1 format to another #wav #ogg
|
76
40
|
* duration # return the duration for a wav or ogg
|
77
41
|
* generate_silence # generates silence in a wav file
|
78
42
|
* play # plays using mplayer
|
79
43
|
* record # alias for capture_desktop
|
44
|
+
* split # split the wav file by silence
|
80
45
|
".strip.lines.map {|x| x[/(?<=\* ).*/]}.sort
|
81
46
|
|
82
47
|
|
@@ -90,7 +55,7 @@ class EasyAudioUtils
|
|
90
55
|
# records audio in mono audio
|
91
56
|
# tested with .flac
|
92
57
|
#
|
93
|
-
def capture()
|
58
|
+
def capture(show: false)
|
94
59
|
|
95
60
|
command = "rec -c 1 -r 8000 -t alsa default #{@file_out} " +
|
96
61
|
"silence 1 0.1 5% 5 1.0 5%"
|
@@ -99,7 +64,7 @@ class EasyAudioUtils
|
|
99
64
|
end
|
100
65
|
|
101
66
|
def concat_files(files=[])
|
102
|
-
|
67
|
+
WavTool.new(out: @file_out, ).concat files
|
103
68
|
end
|
104
69
|
|
105
70
|
alias concat concat_files
|
@@ -107,7 +72,7 @@ class EasyAudioUtils
|
|
107
72
|
def convert()
|
108
73
|
|
109
74
|
if File.extname(@file_in) == '.ogg' then
|
110
|
-
|
75
|
+
ogg_to_wav() if File.extname(@file_out) == '.wav'
|
111
76
|
end
|
112
77
|
|
113
78
|
end
|
@@ -116,9 +81,11 @@ class EasyAudioUtils
|
|
116
81
|
|
117
82
|
case File.extname(@file_in)
|
118
83
|
when '.ogg'
|
119
|
-
|
84
|
+
OggInfo.open(@file_in).length.to_i
|
120
85
|
when '.wav'
|
121
|
-
|
86
|
+
WavTool.new().duration(@file_in)
|
87
|
+
when '.mp3'
|
88
|
+
Mp3Info.new(@file_in).length.to_i
|
122
89
|
end
|
123
90
|
|
124
91
|
end
|
@@ -126,7 +93,7 @@ class EasyAudioUtils
|
|
126
93
|
# silence duration in seconds
|
127
94
|
#
|
128
95
|
def generate_silence(duration)
|
129
|
-
|
96
|
+
WavTool.new(out: @out_file).silence duration: duration
|
130
97
|
end
|
131
98
|
|
132
99
|
alias record capture
|
@@ -135,20 +102,24 @@ class EasyAudioUtils
|
|
135
102
|
command = "mplayer #{@file_out}"
|
136
103
|
run command, show
|
137
104
|
end
|
105
|
+
|
106
|
+
# split by silence
|
107
|
+
#
|
108
|
+
def split(show: false)
|
109
|
+
command = "sox -V3 #{@file_in} #{@file_out} silence -l 0 " +
|
110
|
+
" 1 0.5 0.1% : newfile : restart"
|
111
|
+
run command, show
|
112
|
+
end
|
138
113
|
|
139
114
|
|
140
115
|
private
|
141
116
|
|
142
|
-
def ogg_duration()
|
143
|
-
OggInfo.open(@file_in) {|ogg| ogg.length.to_i }
|
144
|
-
end
|
145
117
|
|
146
118
|
def ogg_to_wav()
|
147
119
|
`oggdec #{@file_in} #{@file_out}`
|
148
|
-
end
|
149
|
-
|
120
|
+
end
|
150
121
|
|
151
|
-
def run(command, show
|
122
|
+
def run(command, show=false)
|
152
123
|
|
153
124
|
if show then
|
154
125
|
command
|
@@ -160,4 +131,3 @@ class EasyAudioUtils
|
|
160
131
|
end
|
161
132
|
|
162
133
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
dpDfnNu4PJKMbhs5rkTRCCzqRiOMqI4xWn62480RqkPqETNnX64MreT1krEQz5R0
|
36
36
|
BC5tUlD1c3rnXPujWY1nNyx0
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-
|
38
|
+
date: 2019-10-25 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: c32
|
@@ -58,25 +58,25 @@ dependencies:
|
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0.2'
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
61
|
+
name: wavetool
|
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
80
|
description:
|
81
81
|
email: james@jamesrobertson.eu
|
82
82
|
executables: []
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.0.
|
106
|
+
rubygems_version: 3.0.3
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: A wrapper for various command-line audio utilities under GNU/Linux.
|
metadata.gz.sig
CHANGED
Binary file
|