diff --git a/Script/pdf2video b/Script/pdf2video index ecff9c5..77c28bd 100755 --- a/Script/pdf2video +++ b/Script/pdf2video @@ -36,7 +36,7 @@ for ((page=1;page<=${page_count};page++)); do source_text=$(cat "${page_text_file}") space_char=" " - split_size=$(( ${#source_text} / 2 )) + split_size=$(( ${#source_text} / 2 + 2)) # Половина с небольшим запасом file_index=0 for ((i=1;i<=${#source_text};i++)); do cur_char=${source_text:$i-1:1} @@ -107,8 +107,10 @@ for ((page=1;page<=${page_count};page++)); do ffmpeg $ffmpeg_pre_options -i "$page_image_file" -i "$page_mp3_file" $ffmpeg_options "$page_mp4_file" + SAVE_IFS=$IFS IFS="" video_file_names_array+=($page_mp4_file) + IFS=$SAVE_IFS rm "$page_mp3_file" diff --git a/Script/txt2mp3_by_yatts b/Script/txt2mp3_by_yatts index a9634e3..f288d59 100755 --- a/Script/txt2mp3_by_yatts +++ b/Script/txt2mp3_by_yatts @@ -6,12 +6,12 @@ speaker='ermil' # (Optional): Speaker voice. Default is zahar. Supported female #["oksana","jane","omazh","zahar","ermil","silaerkan","erkanyavas","alyss", "nick","alena","filipp"] speed='1.0' +# https://stackoverflow.com/questions/16483119/an-example-of-how-to-use-getopts-in-bash + input_file_name="$1" source_text=$(cat "${input_file_name}") -#{ # GUI - # Удаляем все пробелы в начале и в конце строк и заменяем два и более пробелов на один source_text="$(echo -n "$source_text" | sed 's/^ *//;s/[ ^]*$//;s/ */ /g')" @@ -47,32 +47,30 @@ for ((i=1;i<=${#source_text};i++)); do #touch "$audio_file_name" wget -q -O "$audio_file_name" "http://tts.voicetech.yandex.net/tts?format=mp3&quality=hi&lang=ru_RU&speed=$speed&speaker=$speaker&emotion=$emotion&text=${cur_text}" || { echo "Ошибка при загрузке аудио."; exit; } echo "Файл '$audio_file_name' загружен." + + SAVE_IFS=$IFS IFS="" audio_file_names_array+=($audio_file_name) + IFS=$SAVE_IFS cur_text="" fi done -cmd="" -for ((i = 0; i < ${#audio_file_names_array[@]}; i++)) do - cmd="$cmd|${audio_file_names_array[$i]}" -done -cmd=${cmd:1} - out_file="${input_file_name}_yatts.mp3" -echo "Объединяем файлы $cmd в $out_file" -ffmpeg -i "concat:$cmd" -acodec copy "$out_file" - +SAVE_IFS=$IFS IFS="" +echo "Объединяем файлы ${audio_file_names_array[*]} в $out_file" +ffmpeg -f concat -safe 0 -i <(for ((i = 0; i < ${#audio_file_names_array[@]}; i++)) do echo "file '$PWD/${audio_file_names_array[$i]}'"; done) -acodec copy "$out_file" + for ((i = 0; i < ${#audio_file_names_array[@]}; i++)) do f="${audio_file_names_array[$i]}" echo "Удаляем файл '$f'" rm "$f" done +IFS=$SAVE_IFS echo "Конечный файл создан '$out_file'!" -#} | zenity --source_text-info --width=550 --height=450 --title="Озвучивание текста при помощи YaTTS" # GUI