mirror of
https://github.com/jhechavarria/say.sh.git
synced 2025-12-10 06:06:59 +00:00
Debogage global et redaction du README
This commit is contained in:
110
README.md
Normal file
110
README.md
Normal file
@@ -0,0 +1,110 @@
|
||||
# sayy.sh
|
||||
|
||||
This script enables any debian based GNU/Linux distribution to talk! Based on Google's text to speach Android application, it gives you a few commands to ease your TTS experience on Linux.
|
||||
|
||||
## Setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Before installing the script, you will need to install a few dependencies:
|
||||
|
||||
. libttspico-utils
|
||||
. sox
|
||||
. dialog
|
||||
. xsel
|
||||
|
||||
To install all them at once type the following command:
|
||||
|
||||
```
|
||||
sudo apt-get install libttspico-utils sox dialog xsel
|
||||
```
|
||||
|
||||
As libttspico-utils is a non-free package, it may not be available in your default packqge repositories.
|
||||
|
||||
## Install
|
||||
|
||||
To start installing the script simply type:
|
||||
|
||||
```
|
||||
. say.sh install
|
||||
```
|
||||
|
||||
This will go through a few operations required for it to work properly:
|
||||
|
||||
. creation of a /home/user/bin/say directory
|
||||
. moving the script to newly created directory
|
||||
. creating and setting config file within nely created directory
|
||||
. adding an instruction to /gome/user/.bashrc file
|
||||
. reloading .bashrc file
|
||||
|
||||
## Configuration
|
||||
|
||||
During setup a default configuration will be set. You still can change it using the **saycfg** command. This command takes 3 arguments: language, volume and speed.
|
||||
|
||||
Example:
|
||||
|
||||
This command sets language to US English, volume to 1.2 and speed to 0.8
|
||||
|
||||
```
|
||||
saycfg en-US 1.2 0.8
|
||||
```
|
||||
|
||||
The script supports over to 6 different languages. Volume and speed can differ from 0.5 to 1.5.
|
||||
|
||||
### Available languages
|
||||
|
||||
**en-GB** British English
|
||||
|
||||
**en-US** US English
|
||||
**fr-FR** French
|
||||
**de-DE** Deutsch
|
||||
**es-ES** Spanish
|
||||
**it-IT** Italiam
|
||||
|
||||
## Commands
|
||||
|
||||
### say
|
||||
|
||||
Start text interpretation and reading.
|
||||
|
||||
#### Basic usage
|
||||
|
||||
```
|
||||
say Hello World!
|
||||
```
|
||||
|
||||
#### Live changing language
|
||||
|
||||
If default configuration language doesn't fit with a text written in different language, you can overwrite it in command call.
|
||||
|
||||
```
|
||||
say it-IT Buongiorno a tutti!
|
||||
```
|
||||
|
||||
#### Using standard input
|
||||
|
||||
```
|
||||
echo "Salut tout le monde!" | say
|
||||
```
|
||||
|
||||
Even using standard input, language can still be overwrittem:
|
||||
|
||||
```
|
||||
echo "I love this app!" | say en-GB
|
||||
```
|
||||
|
||||
### saycfg
|
||||
|
||||
Set full configuration
|
||||
|
||||
```
|
||||
saycfg es-ES 1 1
|
||||
```
|
||||
|
||||
### saylng
|
||||
|
||||
Sets current languages in configuration
|
||||
|
||||
```
|
||||
saylng de-DE
|
||||
```
|
||||
56
say.sh
56
say.sh
@@ -1,14 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Text file and audio files name that will be used by the script
|
||||
P2WFILE=".say";
|
||||
P2WFILE="say";
|
||||
|
||||
# Set paths
|
||||
ROOTPATH="$HOME/bin/say/"
|
||||
SRCPATH="$ROOTPATH$P2WFILE.sh"
|
||||
CFGPATH="$ROOTPATH$P2WFILE.cfg"
|
||||
SNDPATH="$ROOTPATH$P2WFILE.wav"
|
||||
|
||||
# Accepted languages
|
||||
P2WLNGS=( "en-GB" "en-US" "fr-FR" "de-DE" "it-IT" "es-ES" );
|
||||
|
||||
P2WLNGSNAME=( 'English (British)' 'English (US)' 'French' 'German' 'Italian' 'Spanish' );
|
||||
|
||||
## Checks if language is supported by the synthesiser
|
||||
## Checks if language is supported by synthesiser
|
||||
saysupport()
|
||||
{
|
||||
for i in "${P2WLNGS[@]}"; do
|
||||
@@ -19,10 +24,10 @@ saysupport()
|
||||
return 0;
|
||||
}
|
||||
|
||||
# Set global config: language, volume, speed
|
||||
# Get/Set program config: language, volume, speed
|
||||
saycfg ()
|
||||
{
|
||||
cfg=`cat ~/$P2WFILE.cfg`;
|
||||
cfg=`cat $CFGPATH`;
|
||||
IFS=', ' read -r -a cfg <<< "$cfg";
|
||||
if [ $# -ge 1 ]; then
|
||||
saysupport $1;
|
||||
@@ -43,15 +48,15 @@ saycfg ()
|
||||
fi
|
||||
fi
|
||||
if [ $# -ge 1 ]; then
|
||||
echo "${cfg[*]}" > ~/$P2WFILE.cfg;
|
||||
echo "${cfg[*]}" > $CFGPATH;
|
||||
fi
|
||||
echo "${cfg[*]}";
|
||||
}
|
||||
|
||||
# Change synthesiser lamguage
|
||||
# Get/Set synthesiser lamguage
|
||||
saylng ()
|
||||
{
|
||||
cfg=`cat ~/$P2WFILE.cfg`;
|
||||
cfg=`cat $CFGPATH`;
|
||||
IFS=', ' read -r -a cfg <<< "$cfg";
|
||||
if [ $# -eq 1 ]; then
|
||||
saysupport $1;
|
||||
@@ -91,9 +96,10 @@ shutup ()
|
||||
killall play;
|
||||
}
|
||||
|
||||
# Start synthesiser
|
||||
say ()
|
||||
{
|
||||
cfg=`cat ~/$P2WFILE.cfg`;
|
||||
cfg=`cat $CFGPATH`;
|
||||
IFS=', ' read -r -a cfg <<< "$cfg";
|
||||
text=( "$@" );
|
||||
if [ $# -ge 2 -a -f $2 ]; then
|
||||
@@ -113,20 +119,23 @@ say ()
|
||||
cfg[0]=$1;
|
||||
unset text[0];
|
||||
fi
|
||||
pico2wave -l ${cfg[0]} -w ~/$P2WFILE.wav "${text[*]}";
|
||||
play ~/$P2WFILE.wav vol ${cfg[1]} speed ${cfg[2]};
|
||||
pico2wave -l ${cfg[0]} -w $SNDPATH "${text[*]}";
|
||||
play $SNDPATH vol ${cfg[1]} speed ${cfg[2]};
|
||||
}
|
||||
|
||||
if [[ "$1" = "install" ]]; then
|
||||
if [ ! -d $HOME/bin ] | [ $2 = "f" ]; then
|
||||
mkdir $HOME/bin
|
||||
if [ ! -d "$ROOTPATH" ]; then
|
||||
mkdir -p $ROOTPATH
|
||||
echo "Created directory: $ROOTPATH"
|
||||
fi
|
||||
if [ ! -f $HOME/bin/$P2WFILE.sh ] | [ $2 = "f" ]; then
|
||||
mv ./$P2WFILE.sh $HOME/bin
|
||||
if [ ! -f "$SRCPATH" ]; then
|
||||
mv ./$P2WFILE.sh $ROOTPATH
|
||||
echo "Script moved to: $ROOTPATH directory"
|
||||
fi
|
||||
SYSLNG="`echo $LANGUAGE | sed 's/_/-/g'`";
|
||||
sudo apt-get install libttspico-utils sox dialog xsel;
|
||||
if [ ! -f $HOME/$P2WFILE.cfg ] | [ $2 = "f" ]; then
|
||||
if [ ! -f "$CFGPATH" ]; then
|
||||
SYSLNG="`echo $LANGUAGE | sed 's/_/-/g'`";
|
||||
touch $CFGPATH
|
||||
echo -n "Default config set to: "
|
||||
saysupport $SYSLNG
|
||||
if [ $? -eq 1 ]; then
|
||||
saycfg "$SYSLNG" 1 1;
|
||||
@@ -134,6 +143,15 @@ if [[ "$1" = "install" ]]; then
|
||||
saycfg "en-US" 1 1;
|
||||
fi
|
||||
fi
|
||||
if [ ! "`grep -rnw $HOME/.bashrc -e \". $SRCPATH\"`" > /dev/null ]; then
|
||||
echo ". $SRCPATH" >> "$HOME/.bashrc"
|
||||
echo "Script autoload instruction added to $HOME/.bashrc"
|
||||
source "$HOME/.bashrc"
|
||||
echo "Reloaded source: $HOME/.bashrc"
|
||||
fi
|
||||
if [ "$2" = "d" ]; then
|
||||
sudo apt-get install libttspico-utils sox dialog xsel;
|
||||
fi
|
||||
elif [ "$1" = "config" ]; then
|
||||
saycfg $2 $3 $4;
|
||||
elif [ "$1" = "lang" ] ; then
|
||||
@@ -167,7 +185,7 @@ elif [ "$1" = "lang" ] ; then
|
||||
esac
|
||||
clear
|
||||
elif [ "$1" = "say" ]; then
|
||||
if [ pgrep -x "play" > /dev/null ]; then
|
||||
if [ "`pgrep -x play`" > /dev/null ]; then
|
||||
shutup;
|
||||
else
|
||||
TEXT=`xsel`;
|
||||
|
||||
Reference in New Issue
Block a user