Created
September 2, 2024 10:22
-
-
Save SingularReza/1eaabdb72ffe12ec862c224931d2c9fe to your computer and use it in GitHub Desktop.
A bash script to create WN audiobooks using edge-tts and the text file from whiteleaf's Narou.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #requires edge-tts | |
| #run in the same directory as the text file | |
| read -p 'Enter the filename: ' TEXTFILE | |
| read -p 'Enter voicetype (m/f) (default f): ' VOICE | |
| # turn aozora formatted text into simple text file | |
| perl -pe 's/[#.*?]//g' $TEXTFILE > TMP.txt | |
| #split into chapters to overcome edge tts word limit | |
| mkdir -p chapters && cd chapters | |
| csplit ../TMP.txt '/第.*話/' '{*}' | |
| #loop over each chapter file | |
| FILENAME="" | |
| for FILE in *; do | |
| FILENAME=$(sed -n '1p' $FILE) | |
| mv -f $FILE $FILENAME | |
| echo $FILENAME | |
| if [[ "$VOICE" == "m" ]]; then | |
| edge-tts --voice ja-JP-KeitaNeural --text "$(cat $FILENAME)" --write-media $FILENAME.mp3 & | |
| else | |
| edge-tts --voice ja-JP-NanamiNeural --text "$(cat $FILENAME)" --write-media $FILENAME.mp3 & | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment