Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def convert_to_wav
- if self.prompt.present? and self.prompt.queued_for_write[:original].present?
- data = File.read(self.prompt.queued_for_write[:original].path)
- if self.prompt.content_type == "audio/mp3" || self.prompt.content_type == "audio/mpeg"
- file = Util::AudioConverter.bin_audio_convert(data, "mp3", "wav")
- wavfile = Tempfile.new([self.prompt.original_filename.chomp('.mp3'), ".wav"])
- else
- file = Util::AudioConverter.bin_audio_convert(data, "wav", "wav")
- wavfile = Tempfile.new([self.prompt.original_filename.chomp('.wav'), ".wav"])
- end
- wavfile.binmode
- wavfile.write(file)
- self.prompt = wavfile
- self.prompt_file_name = Digest::MD5.hexdigest(self.prompt_file_name) + ".wav"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment