11f822aaaa | ||
---|---|---|
samples | ||
screenshots | ||
LICENSE | ||
README.md | ||
Sapo.sh | ||
abbreviations.sed | ||
fonetix.sed | ||
letters.sed | ||
sapo-fix-cli.png | ||
sapo-fix-cli.sh | ||
sapo-fix.png | ||
sapo-fix.sh | ||
sapo.png | ||
sapo_progress.png |
README.md
Sapo
The audio book generator
A bash script that can convert .txt files to .wav using the all powerful https://github.com/coqui-ai/TTS
TTS
https://github.com/coqui-ai/TTS
INSTALL TTS
To install TTS, open a terminal and type the following command:
$ pip install TTS
FIX LONG UTTERANCES PROBLEM
In order to be able to process long sentences, follow the instructions in this link:
https://dirk.net/2021/10/31/tts-fix-max-decoder-steps/
OTHER DEPENDENCIES
sudo apt install sed yad sox jq mplayer audacity xed
- As a text editor I use xed. If you prefer, however, another text editor by default (gedit, geany, mousepad etc), please substitute xed in line 23 of Sapo.sh with the respective command of your preffered editor:
EDITOR="xed"
- The same applies for Audacity in line 24 of Sapo.sh. While audacity is not considered an absolute dependency for the functionality of the script, having a wave editor installed might as well be of use in cases, so, such a choice exists in fixing potential errors.
AUDIO_EDITOR="audacity"
SCREENSHOTS
- File selection dialogue:
- The file is delimited to lines with fewer characters each, so there will be no problem with the text-to-speech conversion due to excessively long lines. However, the user can edit the file further before the speech conversion.
- Progress bar , and rough estimate of time left (probably depends on hardware)
DETECTING ERRORS
I. CLUTTER IN AUDIO OUTPUT
Sometimes the output wav file of a text file line is longer than necessary, containing hissing sounds, inrecognisable utterrances and clutter at the end of it.
In order to detect which wave files are generated having that problem, the ratio of character count of line / duration of audio file is calculated. This ratio helps us roughly to estimate which lines were rendered with errors.
The lines that possibly present this problem are written down in the errors.tsv that is generated. After the end of all the lines, the lines written down in the tsv file get re-rendered.
Many times this alone is enough.
At this point the user will be prompted to select editing:
-
All the lines of the file, one by one, where the user can make any change they wish on any word of any line, or
-
Just the lines that were reported with an error during their rendering. These errors have to do with the length of the line, and not with mispronounced words.
Either way, the user is presented with a few options for each line:
These options include:
-
⯈Play the respective audio file
-
🗘Re-render the line, making minor changes(like e.g. putting a fullstop at the end of the line)
-
✀Trim the clutter that exists at the end of audio file, anything that exists after half a second of detected silence.
-
🗡Split render the line text in two batches, that will be concatenated after(useful in long sentences)
-
🛠️Edit the respective audio file with a wave editor(e.g._Audacity)
-
✗Remove the respective audio file directly.
-
⬅️Previous takes the user back to the previous line
-
➡️Next takes the user to the next line
-
👉 Go To can take the user to a specific line number for editing.
-
⏩ Browse will go to the next line and directly play the audio file.
After that, the audio files from all the lines will be concatenated into one.
II. SED SCRIPTS
letters.sed, abbreviations.sed and fonetix.sed are scripts that substitute letters, abbreviations and words that get mispelled with other letter combinations, that have the right pronunciation result, e.g.
s/biscuit/biskit/g
will substitute the word biscuit with the word biskit , the pronunciation of which sounds more proper.
The list of words is growing as the script gets used more, this will be an on going task:
FEEL FREE TO CONTRIBUTE!
It would be really really helpful if you sent me a file containing all the mispronounced words that you have so far encountered. A better pronunciation would be found and recorded in the fonetix.sed database. Thus, the percentage of the mispronounced words would be made less and less.
-
Process complete, the final wav file is inside the created Sapo_filename folder, named filename.wav.
If the wav files (one for each line of text file) are too many, the final wav file will not be produced. In this case concatetate the wav files in smaller batches ( every 500 files), and then concatenate those to the final sound file, using the sox command, for example:
$ cd Sapo_1_1.txt
$ sox {000001..000500}.wav ~/Desktop/1f.wav
$ sox {000501..001000}.wav ~/Desktop/2f.wav
$ sox {001001..001500}.wav ~/Desktop/3f.wav
$ cd ~/Desktop
$ sox {1..3}f.wav final.wav
Sapo-fix.sh
Sapo-fish.sh is the error-correcting routine included in Sapo.sh, that can be run on its own, when the user wants to correct the lines detected and written in errors.tsv.
The user can also edit any line he wishes, just by entering in a line of errors.tsv the respective line number, wav number, and then run Sapo-fix.sh.
DOWNLOAD AND INSTALL
- From the page https://gitlab.com/christosangel/sapo click on the Download button
- and select zip:
- Download the .zip file to your computer(for instance at the Downloads directory):
- Navigate to this directory, right-click on sapo-main.zip, and select Extract Here:
-
Open the terminal, with the following commands you will:
-
navigate to home folder,
$ cd
- create ~/git/sapo directory and copy the contents of the unzipped sapo-main folder in there,
$ mkdir -p ~/git/sapo/ &&cp -r ~/Downloads/sapo-main/* ~/git/sapo/
- make Sapo.sh and sapo-fix.sh executable:
$ chmod +x ~/git/sapo/{Sapo.sh,sapo-fix.sh}
-
Finally, all you have to do to run the script, is either
-
Navigate to ~/git/sapo/ and double-click on Sapo.sh, or
-
from the terminal, run the command:
-
$ ~/git/sapo/Sapo.sh