Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Converter script

  • Loading branch information...
commit b25320da3f70fe05c5f876d6e3490b63b243ab13 1 parent b15bd73
Iain Hecker iain authored

Showing 1 changed file with 60 additions and 0 deletions. Show diff stats Hide diff stats

  1. +60 0 script/convert
60 script/convert
... ... @@ -0,0 +1,60 @@
  1 +#!/bin/bash
  2 +set -e
  3 +
  4 +display-help() {
  5 + echo ""
  6 + echo "This script will convert wav files to mp3 and ogg and add them to soundboss."
  7 + echo ""
  8 + echo " $0 /path/to/sound.wav"
  9 + echo ""
  10 +}
  11 +
  12 +if [ "$1" == "" ]; then
  13 + echo "No file given!"
  14 + display-help
  15 + exit 1
  16 +fi
  17 +
  18 +if [ ! -f $1 ]; then
  19 + echo "Not a file: $1"
  20 + display-help
  21 + exit 1
  22 +fi
  23 +
  24 +
  25 +name=`basename $1 .wav | tr '[A-Z]' '[a-z]'`
  26 +if [ "$name" == "$1" ]; then
  27 + echo "Not a .wav file!"
  28 + display-help
  29 + exit 1
  30 +fi
  31 +
  32 +install() {
  33 + if which brew > /dev/null; then
  34 + echo "Installing $1"
  35 + brew install $1
  36 + else
  37 + echo "Please install $1 to convert a wav"
  38 + exit 1
  39 + fi
  40 +}
  41 +
  42 +if which lame > /dev/null; then
  43 + echo "Lame converter found"
  44 +else
  45 + install "lame"
  46 +fi
  47 +
  48 +if which oggenc > /dev/null; then
  49 + echo "OGG encoder found"
  50 +else
  51 + install "vorbis-tools"
  52 +fi
  53 +
  54 +dir=`cd $(dirname $0)/../public/audio; pwd`
  55 +
  56 +lame -S $1 $dir/$name.mp3
  57 +echo "--> Saved $dir/$name.mp3"
  58 +
  59 +oggenc -Q $1 -o $dir/$name.ogg
  60 +echo "--> Saved $dir/$name.ogg"

0 comments on commit b25320d

Please sign in to comment.
Something went wrong with that request. Please try again.