Je vous explique le principe:
En gros un crontab est effectué toutes les 2min, qui va rechercher la dernière info sur le flux rss que nous appellerons LCI.
Ce titre est copié dans un fichier txt, puis est converti en voix grâce à izsynth
Ce fichier wav est ensuite converti avec ffmpeg pour avoir le même bitrate sur mon fichier wav LCI ( vous allez comprendre)
Ensuite un coup de mpgjoin est fait pour pouvoir coller le fichier texte converti en voix + le fichier wav LCI ( ce qui permet d'annoncer de quelle actualité il s'agit avant de donner l'info )
Puis on recouverti le tout pour avoir un fichier tout propre avec ffmpeg
Le fichier est prêt pour être lu soit avec stream2chromecast soit avec mplayer ou play par exemple
Dites-moi si ça vous plait et surtout si il y a des choses à améliorer?
Il vous faut tout d'abord avoir installé rsstail, izsynth, mpgtx, ffmpeg et stream2chromecast
Code : Tout sélectionner
#!/bin/bash
variable_domoticz="$(curl -s -i -H \"Accept: application/json\" "http://127.0.0.1:8080/json.htm?type=command¶m=getuservariable&idx=15" | grep "\"Value\" : "| awk -F: '{print $2}'|sed 's/,//'|sed 's/ //'| sed 's/\"//g')"
variable_plex="$(curl -s -i -H \"Accept: application/json\" "http://127.0.0.1:8080/json.htm?type=devices&rid=1" | grep "\"Status\" : "| awk -F: '{print $2}'|sed 's/,//'|sed 's/ //'| sed 's/\"//g')"
variable_bonne_nuit="$(curl -s -i -H \"Accept: application/json\" "http://127.0.0.1:8080/json.htm?type=command¶m=getuservariable&idx=7" | grep "\"Value\" : "| awk -F: '{print $2}'|sed 's/,//'|sed 's/ //'| sed 's/\"//g')"
variable_presence="$(curl -s -i -H \"Accept: application/json\" "http://127.0.0.1:8080/json.htm?type=devices&rid=47" | grep "\"Status\" : "| awk -F: '{print $2}'|sed 's/,//'|sed 's/ //'| sed 's/\"//g')"
variable_chromecast="$(curl -s -i -H \"Accept: application/json\" "http://127.0.0.1:8080/json.htm?type=devices&rid=308" | grep "\"Status\" : "| awk -F: '{print $2}'|sed 's/,//'|sed 's/ //'| sed 's/\"//g')"
variable_radios="$(curl -s -i -H \"Accept: application/json\" "http://127.0.0.1:8080/json.htm?type=devices&rid=342" | grep "\"Status\" : "| awk -F: '{print $2}'|sed 's/,//'|sed 's/ //'| sed 's/\"//g')"
variable=$1
# echo "Alertes:"$variable_domoticz;
# echo "Mode Cinema:"$variable_plex;
# echo "Bonne Nuit:"$variable_bonne_nuit;
# echo "Presence:"$variable_presence;
# echo "Chromecast:"$variable_chromecast;
# echo "Radios:"$variable_radio;
# echo $variable
# A suivre est la variable que vous pouvez mettre suivant votre flux rss.
# Le script s'utilise de cette façon: /.rss.sh morandini <- Où Morandini ( oui désole ) est le flux RSS.
if [ "$variable" = "morandini" ]
then
info=$(rsstail -u http://www.jeanmarcmorandini.com/rss.php -n 1 -1 | cut -c8- |sed 's/Regardez//'|sed 's/Video//'|sed 's/VIDEO//'|sed 's/DERNIERE MINUTE: //'|sed 's/-//'|sed 's/ - //'|sed 's/Vidéo//'|sed 's/EN DIRECT - //')
elif [ "$variable" = "geek" ]
then
info=$(rsstail -u http://feeds.feedburner.com/Kulturegeek -n 1 -1 | cut -c8- |sed 's/Title: //')
fi
say()
{ local IFS=+;
echo $info
# Condition possible à enlever, c'est pour ne pas être réveillé en pleine nuit ou que le flux ne se lise pas si je suis absent.
if [ "$variable_bonne_nuit" = "0" ] && [ "$variable_presence" = "On" ] && [ "$variable_plex" = "Off" ] && [ "$variable_radios" = "Off" ]
then
mkdir /home/pi/Audio/
sudo izsynth -t "$info"."" -X 44khz.wav -w -s -o /home/pi/Audio
cd /home/pi/Audio
audio="$(ls -1t | head -1)"
sudo ffmpeg -i /home/pi/Audio/$audio -c:a libmp3lame -b:a 192k /home/pi/Audio/speak_new.mp3
sudo mpgjoin --force -o /dev/shm/out.mp3 /home/pi/Voices/$variable.mp3 /home/pi/Audio/speak_new.mp3
sudo ffmpeg -i /dev/shm/out.mp3 -c:a libmp3lame -b:a 192k /dev/shm/out_new.mp3
if [ "$variable_chromecast" = "On" ]
then
echo "Chromecast allumé !"
# Cette partie permet de baisser le son de ma barre de son pour mieux entendre l'info.
screen -dmS volume_moin_chromecast sudo python /home/pi/stream2chromecast/stream2chromecast.py -devicename 192.168.0.45 -setvol 0.7;
sudo python /home/pi/stream2chromecast/stream2chromecast.py -devicename 192.168.0.29 /dev/shm/out_new.mp3;
sudo python /home/pi/stream2chromecast/stream2chromecast.py -devicename 192.168.0.45 -setvol 1;
# Vous pouvez remplacer par mplayer /dev/shm/out_new.mp3;
sleep 1
sudo rm /dev/shm/out_new.mp3
sudo rm /dev/shm/out.mp3
sudo rm -R /home/pi/Audio/
else
echo "Chromecast Eteint !"
# Alors si le Chromecast est éteint on baisse le son de la télé, via une commande que j'ai fait sur un autre script avec HarmonyHubControl
screen -dmS Baisse_son_tele /home/pi/Scripts/base.sh script_chromecast
screen -dmS Baisse_Google_home sudo python /home/pi/stream2chromecast/stream2chromecast.py -devicename 192.168.0.29 -setvol 0.6;
sudo python /home/pi/stream2chromecast/stream2chromecast.py -devicename 192.168.0.29 /dev/shm/out_new.mp3;
sudo python /home/pi/stream2chromecast/stream2chromecast.py -devicename 192.168.0.29 -setvol 0.7;
sudo rm /dev/shm/out_new.mp3
sudo rm /dev/shm/out.mp3
sudo rm -R /home/pi/Audio/
fi
else
echo "L'une des variables ci dessous est activée:"
echo "Plex: "$variable_plex;
echo "Bonne Nuit: "$variable_bonne_nuit;
echo "Presence: "$variable_presence;
echo "Chromecast: "$variable_chromecast;
echo "Radio: "$variable_radios;
fi
}
if [ "$info" ]
then
# Permet de mettre le dernier flux RSS dans un fichier texte et de le comparer par la suite pour ne pas lire la dernière info en continu...
txt=$(cat /home/pi/Scripts/infos_$variable.txt| tail -c40)
compare_info=$(echo -e $info | tail -c40)
if [ "$compare_info" = "$txt" ]
then
echo "Aucune nouvelle alerte" $variable
else
say $info
fi
else
echo "Aucune Info !"
fi
echo $info > /home/pi/Scripts/infos_$variable.txt
Toute remarque est bonne à prendre !
Voici mon fichier de config izsynth:
Code : Tout sélectionner
# ENGINE SPECIFIC API KEYS
TTS_ENGINE_VOICERSS_APIKEY="TONAPI"
TTS_ENGINE_ISPEECH_APIKEY="TONAPI"
# default tts engine
TTS_ENGINE="naturalreaders"
# default tts voice (null = let tts engine to set default voice. it will use english)
TTS_VOICE="Bruno"
# resynth the file if it already exist
OUTPUT_OVERWRITE="no"
# remove synthesized file after playback
OUTPUT_REMOVE="no"
# assemble and export converted PBX recordings
EXPORT_AUDIO="no"
# assemble and export to the following audio formats
EXPORT_AUDIO_FORMATS="44khz.wav wav gsm ulaw alaw slin"
# split destination audio files into audio formats sub directories
EXPORT_AUDIO_FORMAT_SUBDIR="yes"
# realtime audio playback variables
PLAYBACK="no"
# play the file in background, otherwise foreground
PLAYBACK_BACKGROUND="no"
# command used to play the synthesized audio file
PLAYBACK_COMMAND="mplayer"
# default playback command options
PLAYBACK_COMMAND_OPTS=""
# default playback device
PLAYBACK_DEVICE=""
# sound card playback volume
PLAYBACK_VOLUME=""
# default base temp directory (comment if you want use the system default directory base, ex. /tmp)
TMP_DIR_BASE="/dev/shm"
# default redirect to tmp dir
OUT_DIR="/dev/shm"
# default tts volume
TTS_VOLUME=""
# default wait n. seconds before speaking tts
TTS_PAD_BEGIN="5"
# default wait n. seconds after speaked tts
TTS_PAD_END="5"
# default start music after n. seconds
MUSIC_START="0"
# default fade the start and end of music with 5 seconds
MUSIC_FADE="5"
# default music volume
MUSIC_VOLUME=""
( Pour ça que j'utilise Morandini, ils sont très fort sur le direct lorsqu'il y a un événement... )
Voilà au final de ce que ça peut donner: https://clyp.it/fg01i4bg
Après vous pouvez modifier le fichier de config de izsynth pour améliorer et trouver les voix qu'il convient !
Surtout je suis ouvert à toute modification possible, je suis débutant dans ce domaine