torchaudio 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +8 -8
- data/ext/torchaudio/extconf.rb +1 -10
- data/lib/torchaudio/datasets/utils.rb +4 -2
- data/lib/torchaudio/functional.rb +12 -9
- data/lib/torchaudio/transforms/spectrogram.rb +9 -2
- data/lib/torchaudio/version.rb +1 -1
- data/lib/torchaudio.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f35bd53e4a972f24d5d0a0bfbe8ee45a76a203a535a96043608fa768fee71bf4
|
4
|
+
data.tar.gz: 2a6061fa3aa68c13352ec7c12a79faf85a332163f92b976614fb2f59a1c53d68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f3566e6d1cc9bf1467c39350a4c317c2e192d75851c96d725f4e128be42b9fe9ab9be9c3b6ff33a4ab23f38d7d63b820f001f5b9e4af888f8e8b9b98fe795a5
|
7
|
+
data.tar.gz: bde46760427829d4c9955eba0da00f900425e44cb1fe93c6788691c964949d30d9a47ee3e896df226327294018ea4d4149acc25102e85598394644d5f0e3b568
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# TorchAudio
|
1
|
+
# TorchAudio Ruby
|
2
2
|
|
3
3
|
:fire: An audio library for Torch.rb
|
4
4
|
|
5
|
-
[![Build Status](https://github.com/ankane/torchaudio/workflows/build/badge.svg?branch=master)](https://github.com/ankane/torchaudio/actions)
|
5
|
+
[![Build Status](https://github.com/ankane/torchaudio-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/torchaudio-ruby/actions)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -15,7 +15,7 @@ brew install sox
|
|
15
15
|
Add this line to your application’s Gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem
|
18
|
+
gem "torchaudio"
|
19
19
|
```
|
20
20
|
|
21
21
|
## Getting Started
|
@@ -134,22 +134,22 @@ addons:
|
|
134
134
|
|
135
135
|
## History
|
136
136
|
|
137
|
-
View the [changelog](https://github.com/ankane/torchaudio/blob/master/CHANGELOG.md)
|
137
|
+
View the [changelog](https://github.com/ankane/torchaudio-ruby/blob/master/CHANGELOG.md)
|
138
138
|
|
139
139
|
## Contributing
|
140
140
|
|
141
141
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
142
142
|
|
143
|
-
- [Report bugs](https://github.com/ankane/torchaudio/issues)
|
144
|
-
- Fix bugs and [submit pull requests](https://github.com/ankane/torchaudio/pulls)
|
143
|
+
- [Report bugs](https://github.com/ankane/torchaudio-ruby/issues)
|
144
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/torchaudio-ruby/pulls)
|
145
145
|
- Write, clarify, or fix documentation
|
146
146
|
- Suggest or add new features
|
147
147
|
|
148
148
|
To get started with development:
|
149
149
|
|
150
150
|
```sh
|
151
|
-
git clone https://github.com/ankane/torchaudio.git
|
152
|
-
cd torchaudio
|
151
|
+
git clone https://github.com/ankane/torchaudio-ruby.git
|
152
|
+
cd torchaudio-ruby
|
153
153
|
bundle install
|
154
154
|
bundle exec rake compile
|
155
155
|
bundle exec rake test
|
data/ext/torchaudio/extconf.rb
CHANGED
@@ -20,18 +20,9 @@ $CXXFLAGS += " -D_GLIBCXX_USE_CXX11_ABI=1"
|
|
20
20
|
|
21
21
|
apple_clang = RbConfig::CONFIG["CC_VERSION_MESSAGE"] =~ /apple clang/i
|
22
22
|
|
23
|
-
# check omp first
|
24
|
-
if have_library("omp") || have_library("gomp")
|
25
|
-
$CXXFLAGS += " -Xclang" if apple_clang
|
26
|
-
$CXXFLAGS += " -fopenmp"
|
27
|
-
end
|
28
|
-
|
29
23
|
if apple_clang
|
30
|
-
# silence ruby/intern.h warning
|
31
|
-
$CXXFLAGS += " -Wno-deprecated-register"
|
32
|
-
|
33
24
|
# silence torch warnings
|
34
|
-
$CXXFLAGS += " -Wno-
|
25
|
+
$CXXFLAGS += " -Wno-deprecated-declarations"
|
35
26
|
else
|
36
27
|
# silence rice warnings
|
37
28
|
$CXXFLAGS += " -Wno-noexcept-type"
|
@@ -15,7 +15,9 @@ module TorchAudio
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# follows redirects
|
18
|
-
def download_url_to_file(url, dst, hash_value, hash_type)
|
18
|
+
def download_url_to_file(url, dst, hash_value, hash_type, redirects = 0)
|
19
|
+
raise "Too many redirects" if redirects > 10
|
20
|
+
|
19
21
|
uri = URI(url)
|
20
22
|
tmp = nil
|
21
23
|
location = nil
|
@@ -41,7 +43,7 @@ module TorchAudio
|
|
41
43
|
end
|
42
44
|
|
43
45
|
if location
|
44
|
-
download_url_to_file(location, dst)
|
46
|
+
download_url_to_file(location, dst, hash_value, hash_type, redirects + 1)
|
45
47
|
else
|
46
48
|
# check hash
|
47
49
|
# TODO use hash_type
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module TorchAudio
|
2
2
|
module Functional
|
3
3
|
class << self
|
4
|
-
def spectrogram(waveform, pad, window, n_fft, hop_length, win_length, power, normalized)
|
4
|
+
def spectrogram(waveform, pad, window, n_fft, hop_length, win_length, power, normalized, center: true, pad_mode: "reflect", onesided: true)
|
5
5
|
if pad > 0
|
6
6
|
# TODO add "with torch.no_grad():" back when JIT supports it
|
7
7
|
waveform = Torch::NN::Functional.pad(waveform, [pad, pad], "constant")
|
@@ -19,22 +19,25 @@ module TorchAudio
|
|
19
19
|
hop_length: hop_length,
|
20
20
|
win_length: win_length,
|
21
21
|
window: window,
|
22
|
-
center:
|
23
|
-
pad_mode:
|
22
|
+
center: center,
|
23
|
+
pad_mode: pad_mode,
|
24
24
|
normalized: false,
|
25
|
-
onesided:
|
25
|
+
onesided: onesided,
|
26
|
+
return_complex: true
|
26
27
|
)
|
27
28
|
|
28
29
|
# unpack batch
|
29
|
-
spec_f = spec_f.reshape(shape[0..-2] + spec_f.shape[-
|
30
|
+
spec_f = spec_f.reshape(shape[0..-2] + spec_f.shape[-2..-1])
|
30
31
|
|
31
32
|
if normalized
|
32
|
-
spec_f
|
33
|
+
spec_f /= window.pow(2.0).sum.sqrt
|
33
34
|
end
|
34
|
-
if power
|
35
|
-
|
35
|
+
if !power.nil?
|
36
|
+
if power == 1
|
37
|
+
return spec_f.abs
|
38
|
+
end
|
39
|
+
return spec_f.abs.pow(power)
|
36
40
|
end
|
37
|
-
|
38
41
|
spec_f
|
39
42
|
end
|
40
43
|
|
@@ -3,7 +3,8 @@ module TorchAudio
|
|
3
3
|
class Spectrogram < Torch::NN::Module
|
4
4
|
def initialize(
|
5
5
|
n_fft: 400, win_length: nil, hop_length: nil, pad: 0,
|
6
|
-
window_fn: Torch.method(:hann_window), power: 2.0, normalized: false, wkwargs: nil
|
6
|
+
window_fn: Torch.method(:hann_window), power: 2.0, normalized: false, wkwargs: nil,
|
7
|
+
center: true, pad_mode: "reflect", onesided: true
|
7
8
|
)
|
8
9
|
|
9
10
|
super()
|
@@ -17,10 +18,16 @@ module TorchAudio
|
|
17
18
|
@pad = pad
|
18
19
|
@power = power
|
19
20
|
@normalized = normalized
|
21
|
+
@center = center
|
22
|
+
@pad_mode = pad_mode
|
23
|
+
@onesided = onesided
|
20
24
|
end
|
21
25
|
|
22
26
|
def forward(waveform)
|
23
|
-
F.spectrogram(
|
27
|
+
F.spectrogram(
|
28
|
+
waveform, @pad, @window, @n_fft, @hop_length, @win_length, @power, @normalized,
|
29
|
+
center: @center, pad_mode: @pad_mode, onesided: @onesided
|
30
|
+
)
|
24
31
|
end
|
25
32
|
end
|
26
33
|
end
|
data/lib/torchaudio/version.rb
CHANGED
data/lib/torchaudio.rb
CHANGED
@@ -95,7 +95,7 @@ module TorchAudio
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def save_encinfo(filepath, src, channels_first: true, signalinfo: nil, encodinginfo: nil, filetype: nil)
|
98
|
-
ch_idx,
|
98
|
+
ch_idx, _len_idx = channels_first ? [0, 1] : [1, 0]
|
99
99
|
|
100
100
|
# check if save directory exists
|
101
101
|
abs_dirpath = File.dirname(File.expand_path(filepath))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torchaudio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: torch-rb
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.11.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.11.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rice
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ files:
|
|
74
74
|
- lib/torchaudio/transforms/spectrogram.rb
|
75
75
|
- lib/torchaudio/transforms/vol.rb
|
76
76
|
- lib/torchaudio/version.rb
|
77
|
-
homepage: https://github.com/ankane/torchaudio
|
77
|
+
homepage: https://github.com/ankane/torchaudio-ruby
|
78
78
|
licenses:
|
79
79
|
- BSD-2-Clause
|
80
80
|
metadata: {}
|
@@ -86,14 +86,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '2.
|
89
|
+
version: '2.7'
|
90
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
92
|
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
96
|
+
rubygems_version: 3.3.7
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Data manipulation and transformation for audio signal processing
|