Introduction
Introduction Statistics Contact Development Disclaimer Help
Support 8k 16-bit LE wav samples as if they were raw - warvox - VoIP based ward…
Log
Files
Refs
README
---
commit a9ad034c2ca9d3696f4df97850acb722b6570475
parent 64de9b38015105cdf440fcb6c5bba5e660b8f66d
Author: HD Moore <[email protected]>
Date: Sun, 1 May 2016 23:39:14 -0500
Support 8k 16-bit LE wav samples as if they were raw
Diffstat:
M bin/import_audio.rb | 9 +--------
M lib/warvox/audio/raw.rb | 8 ++++++++
2 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/bin/import_audio.rb b/bin/import_audio.rb
@@ -38,7 +38,7 @@ require 'config/environment'
project_id = ARGV.shift
provider_id = ARGV.shift
-todo = Dir["#{dir}/**/*.raw"].to_a + Dir["#{dir}/**/*.wav"].to_a
+todo = Dir["#{dir}/**/*.{raw,wav}"].to_a
if todo.empty?
$stderr.puts "Error: No raw audio files found within #{dir}"
@@ -115,13 +115,6 @@ todo.each do |rfile|
mr = dr.media
::File.open(rfile, "rb") do |fd|
-
- # Dirty support for RIFF (little-endian) data, WAVE audio, Microsoft PCM, …
- if rfile =~ /\.wav$/
- # Toss the WAV header
- head = fd.read(44)
- end
-
mr.audio = fd.read(fd.stat.size)
mr.save
end
diff --git a/lib/warvox/audio/raw.rb b/lib/warvox/audio/raw.rb
@@ -52,6 +52,14 @@ class Raw
attr_accessor :samples
def initialize(data)
+
+ # Accept raw WAV files, but remove the header
+ if data[ 0,4].to_s == "RIFF" &&
+ data[ 8,4].to_s == "WAVE" &&
+ data[36,4].to_s == "data"
+ data[0, 44] = ''
+ end
+
self.samples = data.unpack('v*').map do |s|
(s > 0x7fff) ? (0x10000 - s) * -1 : s
end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.