Refactor script to generate MP3 files
In this commit, I made several improvements to the 'generate_mp3.sh' script: 1. Removed old complete files before processing to ensure a clean slate. 2. Modified the 'create_mp3_files' function to use '>>' instead of '>' when appending text to the complete files. 3. Updated the comments in the script for better clarity. These changes help maintain a more organized and reliable MP3 generation process. The script now properly appends text to the 'de_complete.txt' and 'es_complete.txt' files, and it removes old complete files before starting the processing. File Changes: - Modified 'generate_mp3.sh' (see diff for details) Note: Please review and test the changes to ensure they meet your requirements.
This commit is contained in:
parent
53000fc607
commit
2badabb616
@ -20,9 +20,11 @@ category_order=("date" "time")
|
||||
txt_dir="/data/scripts/.text"
|
||||
mp3_dir="/data/scripts/.mp3"
|
||||
|
||||
# remove old files
|
||||
rm -f "$txt_dir"/*complete.txt
|
||||
|
||||
# Function to create MP3 files
|
||||
create_mp3_files() {
|
||||
rm -f "$txt_dir"/*complete.txt
|
||||
|
||||
for file in "$txt_dir"/*.txt; do
|
||||
text=$(cat "$file") # Read the content of the file
|
||||
@ -31,12 +33,12 @@ create_mp3_files() {
|
||||
if [[ $file == *de.txt ]]; then
|
||||
# If it's a German file, create a German MP3
|
||||
/data/data/com.termux/files/usr/bin/gtts-cli -l de "$text" --output "$mp3_dir/$base_filename.mp3"
|
||||
echo "$text" > "$txt_dir/de_complete.txt"
|
||||
echo "$text" >> "$txt_dir/de_complete.txt"
|
||||
echo "German MP3 file created: $base_filename.mp3"
|
||||
elif [[ $file != *de.txt ]]; then
|
||||
# If it's a Spanish file, create a Spanish MP3 in slow mode
|
||||
/data/data/com.termux/files/usr/bin/gtts-cli -l es -s "$text" --output "$mp3_dir/$base_filename.mp3"
|
||||
echo "$text" > "$txt_dir/es_complete.txt"
|
||||
echo "$text" >> "$txt_dir/es_complete.txt"
|
||||
echo "Spanish MP3 file created: $base_filename.mp3"
|
||||
else
|
||||
echo "File $file was not processed"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user