OneScriptToRuleThemAll.sh 4.35 KB
#!/bin/bash

#####################################
# File: OneScriptToRuleThemAll.sh   #
# Brief : Script to launch OTMEDIA  #
# Version : 1.0                     #
# Date : 23/07/2013                 #
# Author : Jean-François Rey        #
#####################################

echo -e "OneScriptToRuleThemAll :" 
LORD="                Three::rings
           for:::the::Elven-King
        under:the:sky,:Seven:for:the
      Dwarf-Lords::in::their::halls:of
     stone,:Nine             for:Mortal
    :::Men:::     ________     doomed::to
  die.:One   _,-'...:... \`-.    for:::the
  ::Dark::  ,- .:::::::::::. \`.   Lord::on
 his:dark ,'  .:::::zzz:::::.  \`.  :throne:
 In:::the/    ::::OTMEDIA::::    \ Land::of
 :Mordor:\    ::::SCRIPTS::::    / :where::
 ::the::: '.  '::::YEEEP::::'  ,'  Shadows:
 lie.::One  \`. \`\`:::::::::'' ,'    Ring::to
  ::rule::    \`-._\`\`\`:'''_,-'     ::them::
  all,::One      \`-----'        ring::to
    ::find:::                  them,:One
     Ring:::::to            bring::them
       all::and::in:the:darkness:bind
         them:In:the:Land:of:Mordor
            where:::the::Shadows
                 :::lie.:::"


# Check OTMEDIA_HOME env var
if [ -z ${OTMEDIA_HOME} ]
then 
    OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0)))
    export OTMEDIA_HOME=$OTMEDIA_HOME
fi

# where is OneScriptToRuleThemAll.sh
MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0))

RING=""
p1=0
p2=0
conf=0
exploitconf=0
p3=0
recompose=0
scoring=0

#---------------#
# Parse Options #
#---------------#
while getopts ":hDv:cf:r123CeRs" opt
do
	case $opt in
		h)
			echo -e "$0 [OPTIONS] <WAV_FILE> <OUTPUT_DIRECTORY>\n"
            echo -e "\t Options:"
            echo -e "\t\t-h :\tprint this message"
            echo -e "\t\t-D :\tDEBUG mode on"
            echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode"
            echo -e "\t\t-c :\tCheck process, stop if error detected"
            echo -e "\t\t-f n :\tSpecify a speeral forks number (default 1)"
            echo -e "\t\t-r :\tForce to rerun without deleting all files"
            echo -e "\t\t-a :\tDo every pass"
            echo -e "\t\t-1 :\tDo 1rt pass"
            echo -e "\t\t-2 :\tDo 2nd pass"
            echo -e "\t\t-3 :\tDo 3rd pass"
            echo -e "\t\t-C :\tDo confidence pass"
            echo -e "\t\t-e :\tDo exploit confidence pass (SOLR)"
            echo -e "\t\t-R :\tDo recompose res"
            echo -e "\t\t-s :\tDo scoring"
			exit 1
			;;
		D)
			RING=$RING" -D"
			;;
        v)
            RING=$RING" -v $OPTARG"
            ;;
        c)
            RING=$RING" -c"
            ;;
        f)
            RING=$RING" -f $OPTARG"
            ;;
        r)
            RING=$RING" -r"
            ;;
        a)
            p1=1
            p2=1
            p3=1
            conf=1
            exploitconf=1
            recompose=1
            scoring=1
            ;;
        1)
            p1=1
            ;;
        2)
            p2=1
            ;;
        3)
            p3=1
            ;;
        C)
            conf=1
            ;;
        e)
            exploitconf=1
            ;;
        a)
            recompose=1
            ;;
        s)
            scoring=1
            ;;
		:)
			echo "Option -$OPTARG requires an argument." >&2
			exit 1
			;;
		\?)
			echo "BAD USAGE : unknow opton -$OPTARG"
			exit 1
			;;
	esac
done

# Check USAGE by arguments number
if [ $(($#-($OPTIND-1))) -ne 2 ]
then
	echo "BAD USAGE : $0 [OPTIONS] <WAV_FILE> <OUTPUT_DIR>"
	echo "$0 -h for more info"
	exit 1
fi

shift $((OPTIND-1))
# check audio file - First argument
if [ -e $1 ] && [ -s $1 ]
then
    echo -e "$LORD\n"
    REP_OUT=$2/${1%.*}
    if [ $p1 -eq 1 ];then ${MAIN_SCRIPT_PATH}/FirstPass.sh ${RING} $1 $2;fi
    if [ $p2 -eq 1 ];then ${MAIN_SCRIPT_PATH}/SecondPass.sh ${RING} ${REP_OUT};fi
    if [ $conf -eq 1 ];then $p${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p2";fi
    if [ $exploitconf -eq 1 ]; then ${MAIN_SCRIPT_PATH}/ExploitConfidencePass.sh ${RING} ${REP_OUT};fi
    if [ $p3 -eq 1 ];then ${MAIN_SCRIPT_PATH}/ThirdPass.sh ${RING} ${REP_OUT};fi
    if [ $conf -eq 1 ];then ${MAIN_SCRIPT_PATH}/ConfPass.sh ${RING} ${REP_OUT} "res_p3";fi
    if [ $recompose -eq 1 ];then ${MAIN_SCRIPT_PATH}/RecomposePass.sh ${RING} ${REP_OUT};fi
    if [ $scoring -eq 1 ];then ${MAIN_SCRIPT_PATH}/ScoringRes.sh ${RING} ${REP_OUT};fi
    echo "done"
else
	echo "can't find $1 OR file is empty"
	exit 1
fi