• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Voice data server for navigation voice changer app.


Commit MetaInfo

Revisión9685d51d1190cd90dadacdf5c4989d4cf78eb975 (tree)
Tiempo2013-10-20 00:40:06
AutorHMML <hmml3939@gmai...>
CommiterHMML

Log Message

Fix preview generation for mixed rate/channel data.

Cambiar Resumen

Diferencia incremental

--- a/lib/paperclip_processors/voice_preview.rb
+++ b/lib/paperclip_processors/voice_preview.rb
@@ -38,14 +38,20 @@ class VoicePreview < Paperclip::Processor
3838 end
3939 end
4040 end
41- tfiles.empty? and return dst # give up
42- system(*['sox', tfiles.sort, dst_path].flatten) or raise "Failed to execute sox: #{$?}"
41+ tfiles.empty? and raise "File missing."
42+ tfiles.each do |tf|
43+ `soxi -r "#{tf}"`.to_i == 44100 && `soxi -c "#{tf}"`.to_i == 1 and next
44+ rtmp = "#{tmpdir}/rate-convert-tmp-#{$$}.ogg"
45+ system('sox', tf, '-c', '1', '-r', '44100', rtmp) or raise "Failed on rate/channel conversion, sox fail (#{$?})"
46+ FileUtils.mv rtmp, tf
47+ end
48+ system(*['sox', tfiles.sort, dst_path].flatten) or raise "Failed to concat, sox fail (#{$?})"
4349 rescue => e
44- raise Paperclip::Error, "Error: Failed to generate preview ogg: #{e.message}"
50+ Rails.logger.error "Error: Failed to generate preview voice: #{e.message}"
51+ raise Paperclip::Error, "Error: Failed to generate preview voice: #{e.message}"
4552 ensure
4653 FileUtils.remove_entry_secure tmpdir
4754 end
48-
4955 dst
5056 end
5157 end