Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
JLarky committed Mar 25, 2011
0 parents commit 5b58ed2
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
@@ -0,0 +1,8 @@
file_*
*~
/ru/*.txt*
/en/*.txt*
/ru/[m|M]akefile*
/en/[m|M]akefile*
/ru/*/*
/en/*/*
9 changes: 9 additions & 0 deletions Makefile
@@ -0,0 +1,9 @@
all: ru/Makefile en/Makefile run

run:
(cd ru; make;)
(cd en; make;)

%/Makefile: makefiles/makefile makefiles/makefile_ru makefiles/makefile_en
cp $< $@
cp makefiles/makefile_`dirname $@` `dirname $@`/makefile.inc
26 changes: 26 additions & 0 deletions en/support/makefile
@@ -0,0 +1,26 @@
FILES := $(wildcard file_???)
MP3S := $(FILES:%=%.mp3)
DONES := $(FILES:%=.done.%)

all: file_aaa
$(MAKE) done

file_aaa: src.txt
$(RM) file_???
split -a 3 -l 10 src.txt file_

done: $(MP3S) .done

.done: $(DONES)
touch .done

clean:
$(RM) .done* $(FILES) $(MP3S)

%.mp3: %
rm -f .done .done.$< && echo
~/scripts/festival/convfile_en.sh $< $@ || echo

.done.%: %
test -f $<.mp3 && touch $@ && eyeD3 -a "Festival" -G Speech --set-encoding=utf8 -t "`basename $$PWD`" $(<).mp3

20 changes: 20 additions & 0 deletions makefiles/makefile
@@ -0,0 +1,20 @@
FILES=$(wildcard *.txt)
FILE_NAMES=$(FILES:%.txt=%/src.txt)
DONE_FILES=$(FILES:%.txt=%/.done)
MAKE_FILES=$(FILES:%.txt=%/Makefile)

all: $(FILE_NAMES) $(MAKE_FILES) $(DONE_FILES)

%/src.txt: %.txt
mkdir -p `dirname $@`
cp $< $@
rm -f `dirname $@`/.done

%/.done: %/src.txt
(cd `dirname $@`; nice -n 20 $(MAKE))

%/Makefile: makefile.inc
cp $< $@

sync:
rsync -r ~/festival/ 172.16.0.2:/home/jlarky/sync/festival --progress
26 changes: 26 additions & 0 deletions makefiles/makefile_en
@@ -0,0 +1,26 @@
FILES := $(wildcard file_???)
MP3S := $(FILES:%=%.mp3)
DONES := $(FILES:%=.done.%)

all: file_aaa
$(MAKE) done

file_aaa: src.txt
$(RM) file_???
split -a 3 -l 10 src.txt file_

done: $(MP3S) .done

.done: $(DONES)
touch .done

clean:
$(RM) .done* $(FILES) $(MP3S)

%.mp3: %
rm -f .done .done.$< && echo
../../scripts/convfile_en.sh $< $@ || echo

.done.%: %
test -f $<.mp3 && touch $@ && eyeD3 -a "Festival" -G Speech --set-encoding=utf8 -t "`basename $$PWD`" $(<).mp3

26 changes: 26 additions & 0 deletions makefiles/makefile_ru
@@ -0,0 +1,26 @@
FILES := $(wildcard file_???)
MP3S := $(FILES:%=%.mp3)
DONES := $(FILES:%=.done.%)

all: file_aaa
$(MAKE) done

file_aaa: src.txt
$(RM) file_???
split -a 3 -l 10 src.txt file_

done: $(MP3S) .done

.done: $(DONES)
touch .done

clean:
$(RM) .done* $(FILES) $(MP3S)

%.mp3: %
rm -f .done .done.$< && echo
../../scripts/convfile_ru.sh $< $@ || echo

.done.%: %
test -f $<.mp3 && touch $@ && eyeD3 -a "Festival/ru" -G Speech --set-encoding=utf8 -t "`basename $$PWD`" $(<).mp3

36 changes: 36 additions & 0 deletions ru/convert.py
@@ -0,0 +1,36 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys

if not sys.argv[2:]:
print "usage "+sys.argv[0]+": input output"
exit(0)
else:
f_in, f_out = sys.argv[1:3]

f = open(f_in)
fout = open(f_out, 'w')
line = ''
while 1:
prevline = line
line = f.readline()
line = line.decode("utf-8")

if (len(line)>1) and (173)==ord(line[-2:-1]):
print 123
#line = line.encode("utf-8")
line = line[:-2]
#line = line.decode("utf-8")

char = line[0:1]
if not char.isupper():
prevline = prevline.rstrip('\n')+" "
fout.write(prevline.encode("utf-8"))
if not line: break

fout.write('\n')

f.close()
fout.close()

print "all done, I guess..."
26 changes: 26 additions & 0 deletions ru/support/makefile
@@ -0,0 +1,26 @@
FILES := $(wildcard file_???)
MP3S := $(FILES:%=%.mp3)
DONES := $(FILES:%=.done.%)

all: file_aaa
$(MAKE) done

file_aaa: src.txt
$(RM) file_???
split -a 3 -l 10 src.txt file_

done: $(MP3S) .done

.done: $(DONES)
touch .done

clean:
$(RM) .done* $(FILES) $(MP3S)

%.mp3: %
rm -f .done .done.$< && echo
~/scripts/festival/convfile_ru.sh $< $@ || echo

.done.%: %
test -f $<.mp3 && touch $@ && eyeD3 -a "Festival/ru" -G Speech --set-encoding=utf8 -t "`basename $$PWD`" $(<).mp3

15 changes: 15 additions & 0 deletions scripts/convfile_en.sh
@@ -0,0 +1,15 @@
#!/bin/bash
# http://ru.festivalspeaker.wikia.com

#echo "$1" | text2wave -o - -eval "(voice_msu_ru_nsh_clunits)" | mplayer -
[[ -z "$1" || -z "$2" ]] && echo "usage $0: input output" && exit 1
FILE=`mktemp`
(
[[ -f ".$1.sha1" ]] && sha1sum -c ".$1.sha1" --quiet 1>/dev/null 2>&1 && echo "already converted. remove .$1.sha1 to force" && touch "$2" && exit 0
rm -f "$2"
`dirname $0`/fest2read.sh "$1" $FILE
cat $FILE | text2wave -o - -eval "(audio_mode 'async)" -eval "(voice_ked_diphone)" | lame --abr 16 - "$2"
);
rm -f $FILE

[[ -f "$2" ]] && (echo ok; sha1sum "$1" "$2" > ".$1.sha1") || (echo "Error while speaking file" && exit 1)
15 changes: 15 additions & 0 deletions scripts/convfile_ru.sh
@@ -0,0 +1,15 @@
#!/bin/bash
# http://ru.festivalspeaker.wikia.com

#echo "$1" | text2wave -o - -eval "(voice_msu_ru_nsh_clunits)" | mplayer -
[[ -z "$1" || -z "$2" ]] && echo "usage $0: input output" && exit 1
FILE=`mktemp`
(
[[ -f ".$1.sha1" ]] && sha1sum -c ".$1.sha1" --quiet 1>/dev/null 2>&1 && echo "already converted. remove .$1.sha1 to force" && touch "$2" && exit 0
rm -f "$2"
`dirname $0`/fest2read.sh "$1" $FILE
cat $FILE | text2wave -o - -eval "(audio_mode 'async)" -eval "(voice_msu_ru_nsh_clunits)" | lame --abr 16 - "$2"
);
rm -f $FILE

[[ -f "$2" ]] && (echo ok; sha1sum "$1" "$2" > ".$1.sha1") || (echo "Error while speaking file" && exit 1)
22 changes: 22 additions & 0 deletions scripts/fest2read.sh
@@ -0,0 +1,22 @@
[[ -z $1 || -z $2 ]] && echo "usage $0: input output" && exit 1
cat "$1" |sed -e s/\>//g -e s/\<//g -e s/\ \\.//g -e s/\\//\ /g -e s/–/\ /g -e s/«//g -e s/»//g |
sed -e s/\ ,/,/g |
sed -e s/—/-/g |
sed -e s/…/\./g |
sed -e s/,-/\ /g |
#sed -e s/\.\.\./\ /g |
sed -e s/•//g -e s/“//g -e s/”//g |
sed 's/\([0-9]\),\([0-9]\)/\1\ и\ \2/g' |
sed 's/\([^$\.]\)\.\([^\ ]\)/\1\.\ \2/g' | # добавляет пробел после точек, если его не было
sed -e s/№/номер/g |
sed -e s/www\./ввв\ точка\ /g |
sed -e s/com\./\ точка\ ком/g |
sed -e s/\.ru/\ точка\ ру/g |
sed -e s/%/\ процентов/g -e s/т\\\.д/тд/g -e s/т\\\.п/тп/g -e s/т\\\.е\\\./то\ есть/g -e s/=/равно/g |
sed -e s/д\\\.н\\\.э\\\./до\ нашей\ эры/g -e s/н\\\.э\\\./нашей\ эры/g |
sed -e s/х\\\.ф\\\./художественный\ фильм/g |
sed -e s/\*/a/g |
# ударение
sed -e s/участвовавшим/уча+ствовавши+м/g |
sed -e s/Кэрролла/К+эрролла/g |
sed -e s/Крайону/Край+ону/g > "$2"
11 changes: 11 additions & 0 deletions scripts/sayfile_ru.sh
@@ -0,0 +1,11 @@
#!/bin/bash

[[ -z $1 ]] && echo "usage $0: filename" && exit 1
TMPFILE=/tmp/saytext_ru.mp3
FILE=`mktemp`
(
`dirname $0`/fest2read.sh $1 $FILE
`dirname $0`/convfile_ru.sh $FILE $TMPFILE
padsp mplayer -ao oss $TMPFILE > /dev/null 2>&1
);
rm -f $FILE
6 changes: 6 additions & 0 deletions scripts/saytext_ru.sh
@@ -0,0 +1,6 @@
#!/bin/bash
# http://ru.festivalspeaker.wikia.com

#echo "$1" | text2wave -o - -eval "(voice_msu_ru_nsh_clunits)" | mplayer -
echo "$1" | text2wave -o /tmp/saytext_ru.wav -eval "(voice_msu_ru_nsh_clunits)"
padsp mplayer -ao oss /tmp/saytext_ru.wav > /dev/null 2>&1

0 comments on commit 5b58ed2

Please sign in to comment.