I just wrapped up a quick Bash script, which would feed Festival one sentence after another to speak:
It uses NLTK to split into sentences, I also installed additional voice packs, so it won't sound too weird as you have heard those robotic voices.
The script above was the first testing version, but not going to make it work for any case or everyone. Because...
This thing, listening to story behind, just doesn't work!
I was actually thinking that I could listen to some stories while I am coding. Thought that would be a brilliant idea, but it was an actual distraction. Despite still little robot-like voice, my attention was drawn to the story. Not like the story is or isn't interesting, but it just felt weird as if someone was mumbling next to you.
I tried one of my blog post and a story I randomly grabbed on-line, either of them could work out. I guess, music is still the best companion while you are coding.
#!/bin/bash
exec 3<&0
i=0
while let i++; read line; do
printf "%03d %s\n" "$i" "$line"
if [[ -z $line ]]; then
continue
fi
while :; do
if ! echo "$line" | festival --tts; then
read -p '***' <&3
if [[ $REPLY != "n" ]]; then
continue
fi
fi
break
done
done < <(cat t.txt | python -c "import sys ; import nltk.data ; sent = nltk.data.load('tokenizers/punkt/english.pickle') ; sents = sent.tokenize(sys.stdin.read()) ; print '\n'.join(sents)")
#done < <(xmllint --xpath "//article/div[contains(@class,'post-content')]/text()" <(sed -n '/<article/<\/article/p' | python -c "import sys; import nltk.data ; sent = nltk.data.load('tokenizers/punkt/english.pickle') ; sents = sent.tokenize(sys.stdin.read()) ; print '\n'.join(sents)")
It uses NLTK to split into sentences, I also installed additional voice packs, so it won't sound too weird as you have heard those robotic voices.
The script above was the first testing version, but not going to make it work for any case or everyone. Because...
This thing, listening to story behind, just doesn't work!
I was actually thinking that I could listen to some stories while I am coding. Thought that would be a brilliant idea, but it was an actual distraction. Despite still little robot-like voice, my attention was drawn to the story. Not like the story is or isn't interesting, but it just felt weird as if someone was mumbling next to you.
I tried one of my blog post and a story I randomly grabbed on-line, either of them could work out. I guess, music is still the best companion while you are coding.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.