Permalink
Browse files

clean up gemfie

  • Loading branch information...
1 parent ab83a0d commit 73d0352113065a60c6555b9e93b6525775acbc80 @taf2 committed Apr 5, 2011
Showing with 53 additions and 20 deletions.
  1. +1 −1 Gemfile
  2. +4 −8 Gemfile.lock
  3. +43 −5 bin/wav2txt
  4. +4 −5 merge-wave.c
  5. +1 −1 merge.rb
View
@@ -2,4 +2,4 @@ source :rubygems
gem 'curb'
gem 'json'
-gem 'speech2text', :path => ENV["HOME"] + "/google-speech-to-text/"
+gem 'speech2text', '0.3.4' #:path => ENV["HOME"] + "/google-speech-to-text/"
View
@@ -1,20 +1,16 @@
-PATH
- remote: /Users/taf2/google-speech-to-text
- specs:
- speech2text (0.3.4)
- curb
- json
-
GEM
remote: http://rubygems.org/
specs:
curb (0.7.15)
json (1.5.1)
+ speech2text (0.3.4)
+ curb
+ json
PLATFORMS
ruby
DEPENDENCIES
curb
json
- speech2text!
+ speech2text (= 0.3.4)
View
@@ -15,7 +15,7 @@ end
input = ARGV[0]
-system("./splitter -i #{input} -t 15 -d 0.3 -D 10")
+system("./splitter -i #{input} -t 15 -d 0.2 -D 9")
path = File.dirname(input)
results = []
@@ -35,13 +35,51 @@ chunks = Dir["#{path}/#{root_name}*.wav.chunk*"].sort do|a, b|
end
# now attempt to combine chunks to be as close to 10 seconds as possible
-chunks.each do|chunk|
+accom = Speech::AudioInspector::Duration.new("00:00:00.00")
+merge_set = [] # array of [chunk,duration]
+merged_chunks = []
+chunks.each_with_index do|chunk, i|
inspector = Speech::AudioInspector.new(chunk)
- puts inspector.duration.inspect
+ stamp = inspector.duration
+ accom = accom + stamp
+
+ puts "check: #{accom}, #{accom.to_f}"
+ merge_set << [chunk, stamp]
+
+ if accom.to_f > 9.0
+ last = merge_set.pop
+
+ accom = Speech::AudioInspector::Duration.new("00:00:00.00")
+ merge_set.each {|s| accom = accom + s.last }
+ merged_list = merge_set.map {|c| c.first }.join(' ')
+ merge_name = "merged_chunk#{i}.wav"
+ puts "\tmerge(#{accom.to_s}): #{merge_set.inspect} as #{merge_name}"
+ if merge_set.size == 1
+ system("cp #{merged_list} #{merge_name}")
+ else
+ system("./merge-wave #{merged_list} #{merge_name}")
+ end
+ merged_chunks << merge_name
+
+ merge_set = [last]
+ accom = Speech::AudioInspector::Duration.from_seconds(last.last.to_f)
+ end
+end
+
+if !merge_set.empty?
+ merged_list = merge_set.map {|c| c.first }.join(' ')
+ merge_name = "merged_chunk_last.wav"
+ system("./merge-wave #{merged_list} #{merge_name}")
+ merged_chunks << merge_name
+end
+puts merged_chunks.inspect
+
+# unlink all chunks
+chunks.each do |chunk|
+ File.unlink(chunk)
end
-exit
-chunks.each do|wave|
+merged_chunks.each do|wave|
chunk_file = wave.gsub(/\.wav/,'') + ".wav"
system("mv #{wave} #{chunk_file}")
system("speech2text #{chunk_file}")
View
@@ -38,7 +38,6 @@ int main(int argc, char **argv) {
int *buffer = NULL;
int i = 0;
-
if (argc < 4) {
fprintf(stderr, "usage: %s a1.wav a2.wav ... out.wav\n", argv[0]);
return 1;
@@ -47,17 +46,17 @@ int main(int argc, char **argv) {
memset(&outinfo, 0, sizeof(SF_INFO));
for (i = 1; i < argc-1; ++i ) {
- printf("scan: %s\n", argv[i]);
+ //printf("scan: %s\n", argv[i]);
if (update_output_info(argv[i], &outinfo)) {
return 1;
}
}
- printf("%s will be %.2f seconds\n", argv[3], ((double)outinfo.frames / (double)outinfo.samplerate));
+ printf("%s will be %.2f seconds\n", argv[argc-1], ((double)outinfo.frames / (double)outinfo.samplerate));
- out = sf_open(argv[3], SFM_WRITE, &outinfo);
+ out = sf_open(argv[argc-1], SFM_WRITE, &outinfo);
if (!out) {
- fprintf(stderr, "unable to write file: %s\n", argv[3]);
+ fprintf(stderr, "unable to write file: %s\n", argv[argc-1]);
return 3;
}
View
@@ -6,7 +6,7 @@ class Dur < Speech::AudioInspector::Duration
accom = Dur.new("00:00:00.00")
merge_set = []
-
+# decades
["00:00:00.32",
"00:00:04.73",
"00:00:01.82",

0 comments on commit 73d0352

Please sign in to comment.