]> OzVa Git service - utter-news/commitdiff
Added files and preview audio elements main
authorwill <greenwoodw50@gmail.com>
Mon, 23 Sep 2024 13:57:22 +0000 (14:57 +0100)
committerwill <greenwoodw50@gmail.com>
Mon, 23 Sep 2024 13:57:22 +0000 (14:57 +0100)
.gitignore
assets/energetic_bed.wav [new file with mode: 0644]
assets/generic_bed.wav [new file with mode: 0644]
assets/generic_out.wav [new file with mode: 0644]
assets/mystery_bed.wav [new file with mode: 0644]
assets/weather_bed.wav [new file with mode: 0644]
assets/weather_in.wav [new file with mode: 0644]
index.php
script.sh

index ee889666ef01553b9e643877900de8289c38171f..de2b3140b18a0c703344deecfa07afda22272036 100644 (file)
@@ -1 +1,2 @@
-assets/
+temp.wav
+upload.*
diff --git a/assets/energetic_bed.wav b/assets/energetic_bed.wav
new file mode 100644 (file)
index 0000000..935637f
Binary files /dev/null and b/assets/energetic_bed.wav differ
diff --git a/assets/generic_bed.wav b/assets/generic_bed.wav
new file mode 100644 (file)
index 0000000..c821672
Binary files /dev/null and b/assets/generic_bed.wav differ
diff --git a/assets/generic_out.wav b/assets/generic_out.wav
new file mode 100644 (file)
index 0000000..64909af
Binary files /dev/null and b/assets/generic_out.wav differ
diff --git a/assets/mystery_bed.wav b/assets/mystery_bed.wav
new file mode 100644 (file)
index 0000000..ffb0789
Binary files /dev/null and b/assets/mystery_bed.wav differ
diff --git a/assets/weather_bed.wav b/assets/weather_bed.wav
new file mode 100644 (file)
index 0000000..bde8767
Binary files /dev/null and b/assets/weather_bed.wav differ
diff --git a/assets/weather_in.wav b/assets/weather_in.wav
new file mode 100644 (file)
index 0000000..72b6e71
Binary files /dev/null and b/assets/weather_in.wav differ
index d23acd9b3fd48dfbad695dd350b62b4aee2ba92c..6198a70dc9cbf6555e9b70e2a9dc6d8c4d93766b 100644 (file)
--- a/index.php
+++ b/index.php
@@ -32,34 +32,46 @@ setInterval(getTime, 100);
                <p>.wav, .mp3, .vorbis, .ogg, .aif</p>
                <p style="padding: 5px; color: green; border: 1.5px solid green;">
                        Note from will:<br>
-                       Just waiting on some idents from Jeremy, will hopefully give some more variety in the idents that can be picked! I'll also be building in .mp3 support soon...<br>
+                       Just waiting on some idents from Jeremy, will hopefully give some more variety in the idents that can be picked!<br>
                        Also if anything goes wrong pls let me know asap!
                </p>
                <form action="./index.php" method="post" enctype="multipart/form-data">
                        <fieldset>
                                <legend>Front ident</legend>
-                               <input type="radio" name="frontId" id="frontId" value="assets/front_news.wav" checked="checked"/>
-                               <label for="frontId">Utter news generic</label>
+                               <input type="radio" name="frontId" id="frontId" value="weather_in" checked="checked"/>
+                               <label for="frontId">Weather front ident</label><br>
+                               <audio controls src="assets/weather_in.wav"></audio><br>
                        </fieldset>
 
                        <fieldset>
                                <legend>Bed</legend>
-                               <input type="radio" name="bed" id="bed" value="assets/bed_news.wav" checked="checked"/>
-                               <label for="bed">Utter news generic</label>
+                               <input type="radio" name="bedId" id="bedId" value="energetic_bed" checked="checked"/>
+                               <label for="bedId">Energetic bed</label><br>
+                               <audio controls src="assets/energetic_bed.wav"></audio><br>
+                               <input type="radio" name="bedId" id="bedId" value="weather_bed" checked="checked"/>
+                               <label for="bedId">Weather bed</label><br>
+                               <audio controls src="assets/weather_bed.wav"></audio><br>
+                               <input type="radio" name="bedId" id="bedId" value="mystery_bed" checked="checked"/>
+                               <label for="bedId">Mystery bed</label><br>
+                               <audio controls src="assets/mystery_bed.wav"></audio><br>
+                               <input type="radio" name="bedId" id="bedId" value="generic_bed" checked="checked"/>
+                               <label for="bedId">Utter news generic</label><br>
+                               <audio controls src="assets/generic_bed.wav"></audio><br>
                        </fieldset>
 
                        <fieldset>
                                <legend>Back ident</legend>
-                               <input type="radio" name="backId" id="backId" value="assets/back_news.wav" checked="checked"/>
-                               <label for="backId">Utter news generic</label>
+                               <input type="radio" name="backId" id="backId" value="generic_out" checked="checked"/>
+                               <label for="backId">Utter news generic</label><br>
+                               <audio controls src="assets/generic_out.wav"></audio><br>
                        </fieldset>
                        <br><label for="file">Select a file (.wav)</label>
                        <br><input type="file" id="file" name="file"/>
                        <br><br><input type="submit" name="upload" value="upload"/>
                        <br><br><output>
 <?php
-error_reporting(E_ALL);
-ini_set('display_errors', 'On');
+error_reporting(E_ALL);
+ini_set('display_errors', 'On');
 
 if (!empty($_POST['upload'])) {
        echo "Uploading...<br>";
@@ -88,11 +100,13 @@ if (!empty($_POST['upload'])) {
 
                $output=null;
                $retval=null;
-               exec("./script.sh", $output, $retval);
+               exec("./script.sh -i $frontId -b $bedId -o $backId", $output, $retval);
                $output = var_export($output, true);
                if ($retval == "0") {
                        echo "<span class='green'>Finished processing successfully.</span><br><br>";
                        echo "<audio controls src='assets/news.wav' />";
+               } else {
+                       echo "<span class='utter'>Error! (code $retval)<br>$output</span>";
                }
        } else {
                echo "<span class='utter'>Sorry, there was an error uploading your file.</span>";
index 8dcb700ac7dfab825f28059c410eb7a46b0af7ef..8bc8ea443f762344ecfb96d651d85a202cb11d84 100755 (executable)
--- a/script.sh
+++ b/script.sh
@@ -1,3 +1,33 @@
+POSITIONAL_ARGS=()
+
+while [[ $# -gt 0 ]]; do
+  case $1 in
+    -i|--in-ident)
+      IN_IDENT="$2"
+      shift # past argument
+      shift # past value
+      ;;
+    -b|--bed)
+      BED="$2"
+      shift # past argument
+      shift # past value
+      ;;
+    -o|--out-ident)
+      OUT_IDENT="$2"
+      shift # past argument
+      shift # past value
+      ;;
+    -*|--*)
+      echo "Unknown option $1"
+      exit 1
+      ;;
+    *)
+      POSITIONAL_ARGS+=("$1") # save positional arg
+      shift # past argument
+      ;;
+  esac
+done
+
 sox assets/upload.wav -c 1 -r 48k assets/temp.wav \
 norm -3 \
 silence -l 1 0.1 1% -1 2.0 1% \
@@ -11,10 +41,10 @@ length=$(soxi -s assets/temp.wav)
 length=$((length + padding))
 
 sox assets/temp.wav assets/vox.wav pad "$fadein"s 0
-sox assets/bed_news.wav assets/temp.wav \
+sox assets/"$BED".wav assets/temp.wav \
 trim 0s "$length"s \
 fade 0 -0 "$fadeout"s
 
-sox assets/front_news.wav "|sox -M assets/vox.wav assets/temp.wav -c 1 -t sox -" assets/back_news.wav assets/news.mp3 norm -3
+sox assets/"$IN_IDENT".wav "|sox -M assets/vox.wav assets/temp.wav -c 1 -t sox -" assets/"$OUT_IDENT".wav assets/news.mp3 norm -3
 
 exit 0