#!/bin/bash

# Dialogs separated by pipes
dialogs="You|are|in|a|room|there|is|a|door|10|paces|in|front|of|you|There|is|a|humungous|spider|chopping|away|at|this|difficult|raspberry|elemental|suffocating"

# Directory to store .wav files
dir="$PWD"

# Convert each dialog into a .wav file
OLDIFS=$IFS
IFS='|' 
for dialog in $dialogs; do
    # Replace spaces and special characters with underscores
    filename=$(echo "$dialog" | tr -dc '[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]' | tr ' ' '_')
    
    # Use espeak-ng to convert the dialog into a .wav file
    espeak-ng -w "$dir/audio/$filename.wav" -s 150 -v en-us "$dialog"
done
IFS=$OLDIFS

