Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
Last active October 9, 2024 01:17
Show Gist options
  • Save fabiolimace/41cda6b88d5431f65ab63f1cfb0fc32c to your computer and use it in GitHub Desktop.
Save fabiolimace/41cda6b88d5431f65ab63f1cfb0fc32c to your computer and use it in GitHub Desktop.
espeak-ng-say-list.sh: A scritp that says a list of words, until you answer good or not for each one of them.
#!/bin/bash
#
# A scritp that says a list of words, until you answer good or not for each one of them.
#
# The answers are logged into a file called `espeak-ng-say-list.log`.
#
# Usage:
#
# espeak-ng-say-list.sh LIST [VOICE]
#
# y or Y: the word has a good pronunciation
# n or N: the word has a bad pronunciation
# ENTER: speak the word again
# CTRL+C: stop program
#
# The default voice is `pt-br`
#
list=$1
voice=${2-pt-br}
output=espeak-ng-say-list.log
[ -f "${list}" ] || exit 1;
for word in $(cat "${list}"); do
while true;
do
echo --------------------------------
espeak-ng -v $voice "$word" -X;
espeak-ng -q -v $voice "$word" --ipa;
echo
read -n 1 -p "Is it good? [y/n]: " option
case $option in
[yY] )
echo -e "$word\t$(espeak-ng -q -v $voice "$word" -x)\t$(espeak-ng -q -v $voice "$word" --ipa)\tGOOD" >> $output;
echo; break
;;
[nN] )
echo -e "$word\t$(espeak-ng -q -v $voice "$word" -x)\t$(espeak-ng -q -v $voice "$word" --ipa)\tBAD" >> $output;
echo; break
;;
*)
continue;
;;
esac
done;
done
echo --------------------------------
echo "cat \"$output\"";
cat "$output";
@fabiolimace
Copy link
Author

fabiolimace commented Oct 9, 2024

Arquivo de teste lista.txt:

Teste
Marcia
Márcia
Ana Lucia
Ana Lúcia

Resultado do teste:

./espeak-ng-say-list.sh lista.txt
--------------------------------
Translate 'teste'
  1	t        [t]

  1	e        [e]
 48	e (stL04_ [E]

  1	s        [s]

  1	t        [t]
 38	?2 t (e_ [tS]

 22	e (_     [,y]
  1	e        [e]

t'EstSy
tˈɛstʃy

Is it good? [y/n]: y
--------------------------------
Translate 'marcia'
  1	m        [m]

  1	a        [a]

  1	r        [*]
 20	r (C     [*@-]

  1	c        [k]
 21	c (Y     [s]

 36	i (L04_  ['i]
  1	i        [i]
 22	i (a     [i]
 21	i (A     [j]

 41	&) a (_  [,&]
  1	a        [a]

m,a*@-s'i;&
mˌaɾəsˈiæ

Is it good? [y/n]: n
--------------------------------
Translate 'márcia'
  1	m        [m]

 36	á       [''a]

  1	r        [*]
 20	r (C     [*@-]

  1	c        [k]
 21	c (Y     [s]

 36	i (L04_  ['i]
  1	i        [i]
 22	i (a     [i]
 87	áCC) i (A_ [j]
 21	i (A     [j]

 41	&) a (_  [,&]
  1	a        [a]

m'a*@-sj&
mˈaɾəsjæ

Is it good? [y/n]: y
--------------------------------
Translate 'ana'
  1	a        [a]
 22	a (n     [&~]

  1	n        [n]

 41	&) a (_  [,&]
  1	a        [a]

'&~n&
ˈɐ̃næ

Is it good? [y/n]: y
--------------------------------
Translate 'lucia'
  1	l        [l]

  1	u        [u]

  1	c        [k]
 21	c (Y     [s]

 36	i (L04_  ['i]
  1	i        [i]
 22	i (a     [i]
 21	i (A     [j]

 41	&) a (_  [,&]
  1	a        [a]

l,us'i;&
lˌusˈiæ

Is it good? [y/n]: n
--------------------------------
Translate 'ana'
  1	a        [a]
 22	a (n     [&~]

  1	n        [n]

 41	&) a (_  [,&]
  1	a        [a]

'&~n&
ˈɐ̃næ

Is it good? [y/n]: y
--------------------------------
Translate 'lúcia'
  1	l        [l]

 36	ú       [''u]

  1	c        [k]
 21	c (Y     [s]

 36	i (L04_  ['i]
  1	i        [i]
 22	i (a     [i]
 72	úC) i (A_ [j]
 21	i (A     [j]

 41	&) a (_  [,&]
  1	a        [a]

l'usj&
lˈusjæ

Is it good? [y/n]: y
--------------------------------
cat "espeak-ng-say-list.log"
Teste	t'EstSy	tˈɛstʃy	GOOD
Marcia	m,a*@-s'i;&	mˌaɾəsˈiæ	BAD
Márcia	m'a*@-sj&	mˈaɾəsjæ	GOOD
Ana	'&~n&	ˈɐ̃næ	GOOD
Lucia	l,us'i;&	lˌusˈiæ	BAD
Ana	'&~n&	ˈɐ̃næ	GOOD
Lúcia	l'usj&	lˈusjæ	GOOD
Word Kirshenbaum IPA Good or Bad?
Teste t'EstSy tˈɛstʃy GOOD
Marcia m,a*@-s'i;& mˌaɾəsˈiæ BAD
Márcia m'a*@-sj& mˈaɾəsjæ GOOD
Ana '&~n& ˈɐ̃næ GOOD
Lucia l,us'i;& lˌusˈiæ BAD
Ana '&~n& ˈɐ̃næ GOOD
Lúcia l'usj& lˈusjæ GOOD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment