📜 ⬆️ ⬇️

We write in Twitter voice

The topic may seem "jaded", but suddenly someone will come in handy. Somehow dug in the direction of Google Speech Recognition and its implementation in Chrome. And the thought came to mind to write a simple script for posting to Twitter in a voice. Recognition of course is not very special - but such phrases as “went for mushrooms” or “departed” - perceives quite adequately. At home - Ubuntu OS - for deb-like systems - everything will be described.

First you need to install these packages:

sudo apt-get install rec sudo apt-get install flac sudo apt-get install sox sudo apt-get install sed sudo apt-get install ttytter 


Ttytter must be configured (get a pin and set on your tape).
')
And actually execute the script on Bash:

 #!/bin/bash FILEWAV="sound.wav" #      FILEFLAC="sound.flac" #   flac #echo "Recording from microphone..." rec -r 16000 -b 16 -c 1 $FILEWAV >/dev/null 2>&1 & echo "Tweeting this speech..." read KEYPRESSED # killall rec #   flac sox $FILEWAV $FILEFLAC gain -n -5 silence 1 5 2% #   wav- rm $FILEWAV echo "You said: " wget -q -U "Mozilla/5.0" --post-file $FILEFLAC --header="Content-Type: audio/x-flac; rate=16000" -O - "http://www.google.com/speech-api/v1/recognize?lang=ru-RU&client=chromium" > test.ret cat test.ret | sed 's/.*utterance":"//' | sed 's/","confidence.*//' > test.txt rm test.ret TWITEXT="$(cat test.txt)" echo $TWITEXT ttytter -status="$TWITEXT" 


Thank you all for your attention. Maybe someone will need. Ps in the bash is not strong - and it was hard to figure it out - I know that a lot at the end of any nonsense that could be easier written - but who needs it - will correct it.

Source: https://habr.com/ru/post/150317/


All Articles