izSynth: make domoticz talk with many TTS engines in a easy way

All kinds of 'OS' scripts

Moderator: leecollings

jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by jmleglise »

jin wrote:
jmleglise wrote:Hi,

Another feedback : I would appreciate in a future version an option to don't keep the audio file after the playback. Indeed, some sentences will never come again. (like reading news).
(for saving some disk space)

Code: Select all

jin@jlt:~$ izsynth -h | grep keep
  -w                         Overwrite the synthesized file, otherwise keep it (current: no)
otherwise you can change the default behavior via izsynth.conf file:

set:

Code: Select all

PLAYBACK_RESYNTH="yes"
Read the domoticz wiki page to discover:

http://www.domoticz.com/wiki/IzSynth

With kind regards
Hi jin,

1/ That's not what I am meaning. I ask for an option to automatically remove the .wav in dev/shm after the playback. something like "-nocache"
It's not the purpose of -w => overwrite the file if the same sentence come again.
As my RPi never reboots, what will happen when the /dev/shm will become full ?

2/ And another feedback :
Your system can't handle sentences longer than the limit of file name length. (255). This is too short. As my system synthetizes news in the morning, I frequently need >400 chars.
So , for this kind of use, you may have an option, that use a short file name, and then delete it.
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
jin
Posts: 62
Joined: Thursday 18 September 2014 20:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by jin »

jmleglise wrote: Hi jin,

1/ That's not what I am meaning. I ask for an option to automatically remove the .wav in dev/shm after the playback. something like "-nocache"
It's not the purpose of -w => overwrite the file if the same sentence come again.
As my RPi never reboots, what will happen when the /dev/shm will become full ?

2/ And another feedback :
Your system can't handle sentences longer than the limit of file name length. (255). This is too short. As my system synthetizes news in the morning, I frequently need >400 chars.
So , for this kind of use, you may have an option, that use a short file name, and then delete it.
Ok thanks now understand your request :)

1) izsynth is thought to generate reusable over the time audio files.
anyway your request is useful and easy to implement, so I just pushed to github an update implementing this feature:

Code: Select all

jin@jlt:~$ izsynth | grep Remove
  -r                         Remove synthesized file after playback
ps. if we must remove the synthesized file, of course we can't remove it if PLAYBACK_BACKGROUND=yes


2) If you need to synthesize phrases longer than 255 chars, then use as input file a txt file (anyway the limit of synthesized chars depend on engine used, so you must try some engines to find what offer the longer output)... you can accomplish that using a script that make a txt file with your news in the same path, for example:

Code: Select all

curl -s http://yournewssite.com | sed 's|</b>|-|g' | sed 's|<[^>]*>||g' > /dev/shm/news.txt
izsynth -i /dev/shm/news.txt
Thank you for the feedback

With kind regards
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by jmleglise »

Hi,

1/ Thank you for the "-r" . Great reactivity ! :D

2/ For my second point (long sentence), using an intermediate file.txt is not convenient. In my Lua script, I am used to launch the TTS in a single command . For example, you can see my use here : http://www.domoticz.com/forum/viewtopic ... 23&t=10923

So, can you advise me something to avoid this file.txt ? (ie : is it possible in linux to redirect the stdin to your -i parameter ?)

Or here is another idea as my 2 points are linked :
Short sentences : it 's usefull to cache them (good chance to get it again)
Very Long sentence : no need to cache. (and no need to use the sentence as the filename. This will remove the length limit).
So you may code a : if length(sentence)>255 then use filename "tmp.wav" and then remove it at the end ?

You see my idea ?
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
jin
Posts: 62
Joined: Thursday 18 September 2014 20:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by jin »

jmleglise wrote:Hi,

1/ Thank you for the "-r" . Great reactivity ! :D

2/ For my second point (long sentence), using an intermediate file.txt is not convenient. In my Lua script, I am used to launch the TTS in a single command . For example, you can see my use here : http://www.domoticz.com/forum/viewtopic ... 23&t=10923

So, can you advise me something to avoid this file.txt ? (ie : is it possible in linux to redirect the stdin to your -i parameter ?)

Or here is another idea as my 2 points are linked :
Short sentences : it 's usefull to cache them (good chance to get it again)
Very Long sentence : no need to cache. (and no need to use the sentence as the filename. This will remove the length limit).
So you may code a : if length(sentence)>255 then use filename "tmp.wav" and then remove it at the end ?

You see my idea ?

jmleglise nice ideas, I'm working on :)

download the new version from github, this is the changelog:

Code: Select all

# - restored google tts support (limited to 160 chars max)
# - added -r option for removing synthesized file after playback
# - added support for stdin as input stream, example:
#   echo this is only a test | izsynth -
so you can pipe in three ways:

echo "Good morning" | izsynth -
echo "Good morning" | izsynth -i -
echo "Good morning" | izsynth -t -

I suggest the first because is shortest :)

anyway right now the limit is 255 chars

TODO:
- add support for automatically no keep long synthesized sentence (>= 255 chars)
- find a way to split and synthesize sentence longer than the supported engine chars (splitting them and making more request to the online engine)

Kind regards
korniza
Posts: 157
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6028
Location: Greece
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by korniza »

You are my hero! I know that it looks so easy but I know that it is hard to get all these tts engines inside a script.
IMHO, it can be a nice app for mydomoticz, where can be a databse of common phrases which will be updated by domoticz users and shared to all.
As you may have some requests please add another one: ispeech! voices are not so natural but they have a variety of languages.
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
jin
Posts: 62
Joined: Thursday 18 September 2014 20:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by jin »

korniza wrote:You are my hero! I know that it looks so easy but I know that it is hard to get all these tts engines inside a script.
IMHO, it can be a nice app for mydomoticz, where can be a databse of common phrases which will be updated by domoticz users and shared to all.
As you may have some requests please add another one: ispeech! voices are not so natural but they have a variety of languages.
Hi korniza,

thank you for your positive post :)

check the latest github commit ;)

Code: Select all

[jin@jlt ~]$ izsynth -e ispeech -l
Voice                Country     Language    Gender
-------------------- ----------- ----------- ------
usenglishfemale      US          English     Female
usenglishmale        US          English     Male
ukenglishfemale      UK          English     Female
ukenglishmale        UK          English     Male
auenglishfemale      Australian  English     Female
usspanishfemale      US          Spanish     Female
usspanishmale        US          Spanish     Male
chchinesefemale      China       Chinese     Female
hkchinesefemale      HongKong    Catonese    Female
twchinesefemale      Taiwan      Chinese     Female
jpjapanesefemale     Japan       Japanese    Female
krkoreanfemale       Korea       Korean      Female
caenglishfemale      Canadian    English     Female
huhungarianfemale    Hungary     Hungarian   Female
brportuguesefemale   Brazilian   Portuguese  Female
eurportuguesefemale  European    Portuguese  Female
eurportuguesemale    European    Portuguese  Male
eurspanishfemale     European    Spanish     Female
eurspanishmale       European    Spanish     Male
eurcatalanfemale     European    Catalan     Female
eurczechfemale       European    Czech       Female
eurdanishfemale      European    Danish      Female
eurfinnishfemale     European    Finnish     Female
eurfrenchfemale      European    French      Female
eurfrenchmale        European    French      Male
eurnorwegianfemale   European    Norweigian  Female
eurdutchfemale       European    Dutch       Female
eurpolishfemale      European    Polish      Female
euritalianfemale     European    Italian     Female
euritalianmale       European    Italian     Male
eurturkishfemale     European    Turkish     Female
eurturkishmale       European    Turkish     Male
eurgreekfemale       European    Greek       Female
eurgermanfemale      European    German      Female
eurgermanmale        European    German      Male
rurussianfemale      Russia      Russian     Female
rurussianmale        Russia      Russian     Male
swswedishfemale      Sweden      Swedish     Female
cafrenchfemale       Canadian    French      Female
cafrenchmale         Canadian    French      Male
arabicmale           Dubai       Arabic      Male
Kind regards
korniza
Posts: 157
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6028
Location: Greece
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by korniza »

OMG!!!!!!yes! I'm dreaming! YOU made it once again! jin the great hero of TTS! THE ultimate script for TTS! If in case you find any greek male tts, please add it. :lol: :lol: :D
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by woody4165 »

Ciao jin

this tool is becoming wonderful every day.

One question regarding these warnings:

Code: Select all

mkdir: cannot create directory ‘/home/pi/.config/izsynth’: Permission denied
find: `/home/pi/.config/izsynth/engines/': No such file or directory
find: `/home/pi/.config/izsynth/engines/': No such file or directory
I get them if I execute izsynth without sudo (I followed the github and wiki to install it), is it correct that I need to launch it this way?

Thanks
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
jin
Posts: 62
Joined: Thursday 18 September 2014 20:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by jin »

woody4165 wrote:Ciao jin

Code: Select all

mkdir: cannot create directory ‘/home/pi/.config/izsynth’: Permission denied
find: `/home/pi/.config/izsynth/engines/': No such file or directory
find: `/home/pi/.config/izsynth/engines/': No such file or directory
I get them if I execute izsynth without sudo (I followed the github and wiki to install it), is it correct that I need to launch it this way?

Thanks
Ciao woody! :)

can you run this command and paste here the output?

Code: Select all

ls -al /home/pi/.config/
and after:

Code: Select all

chown pi:pi /home/pi/.config/
chown pi:pi /home/pi/.config/izsynth
let's me know if this fix

Kind regards
jin
Posts: 62
Joined: Thursday 18 September 2014 20:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by jin »

korniza wrote:OMG!!!!!!yes! I'm dreaming! YOU made it once again! jin the great hero of TTS! THE ultimate script for TTS! If in case you find any greek male tts, please add it. :lol: :lol: :D
Thank you! ;)
korniza
Posts: 157
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6028
Location: Greece
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by korniza »

Feedback report: I face an issue with non-english prompt. I tried to insert the following on Action
script://izsynth -e ispeech -v eurgreekfemale -t "Καλημέρα!"
Domoticz refuse to save it (pressing save, don't do anything). It is related with domoticz by itself as izsynth is working when using the same prompt on console.
Jin is there any workaround that can be used to your script? Also I may missing something: can I get big texts played (for example a web page feed) breaking into smaller files and putting together?
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
toreandre
Posts: 91
Joined: Tuesday 19 January 2016 12:51
Target OS: -
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by toreandre »

jin wrote:

Code: Select all

pi@raspberrypi ~ $ which file
/usr/bin/file
pi@raspberrypi ~ $ dpkg -S /usr/bin/file
file: /usr/bin/file
can you run:

Code: Select all

sudo apt-get install file
izsynth is a bash script and it use many system commands to do the job, so these commands must be installed :)

just updated wiki, thanks!

let's me know is something is still missing.

kind regards
Worked like a charm! Now i can use this to play sound " /home/osmc/domoticz/scripts/izsynth -e voicerss -v nb-no -t "Hei, jeg heter test""

But i have some trouble using it with a switch.
All of the actions on this selector gives error in domoticz.
Attachments
Log
Log
izsynth2.png (15.31 KiB) Viewed 4415 times
Actions
Actions
izsynth.png (20.49 KiB) Viewed 4415 times
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by woody4165 »

What is the permission of the file /home/osmc/domoticz/scripts/izsynth?

try to change to 755
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
toreandre
Posts: 91
Joined: Tuesday 19 January 2016 12:51
Target OS: -
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by toreandre »

Thank you for the suggestion Woody, seems like the fix was to add "&" at the end of the action.

seems like the script is executing (no error in log) but no sound from the speakers, so i need to check the soundcard output in config.
jin
Posts: 62
Joined: Thursday 18 September 2014 20:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by jin »

korniza wrote: Also I may missing something: can I get big texts played (for example a web page feed) breaking into smaller files and putting together?
This is in the TODO list :)

about the non english test, this is a Domoticz problem I think :( open a bug report.

Kind regards
micbou
Posts: 86
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NL
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by micbou »

Adding a '&' right after the action fixed the return 256 error for me, but now I'm not getting any audio from the action. Same as someone mentioned above me. FYI, audio is working when executing the script from the command prompt.

Any advice?
snip_20160503140701.png
snip_20160503140701.png (186.4 KiB) Viewed 4389 times
jin
Posts: 62
Joined: Thursday 18 September 2014 20:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by jin »

micbou wrote:Adding a '&' right after the action fixed the return 256 error for me, but now I'm not getting any audio from the action. Same as someone mentioned above me. FYI, audio is working when executing the script from the command prompt.
Any advice?
Yuo must add '&' at the end?
This is very strange... my domoticz installation works out of the box simply using

script://izsynth test message

from you domoticz directory, can you paste the output of:

Code: Select all

ls -al scripts/izsynth 
toreandre
Posts: 91
Joined: Tuesday 19 January 2016 12:51
Target OS: -
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by toreandre »

jin wrote:
micbou wrote:Adding a '&' right after the action fixed the return 256 error for me, but now I'm not getting any audio from the action. Same as someone mentioned above me. FYI, audio is working when executing the script from the command prompt.
Any advice?
Yuo must add '&' at the end?
This is very strange... my domoticz installation works out of the box simply using

script://izsynth test message

from you domoticz directory, can you paste the output of:

Code: Select all

ls -al scripts/izsynth 

Code: Select all

osmc@osmcsoverom:~/domoticz$ ls -al scripts/izsynth
-rwxrwxrwx 1 osmc osmc 41084 Apr 28 19:03 scripts/izsynth
Domoticz is also running under the user "osmc"
micbou
Posts: 86
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NL
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by micbou »

Code: Select all

root@raspberrypi:/home/pi/domoticz# ls -al scripts/izsynth
-rwxrwxr-x 1 pi pi 50041 May  3 14:05 scripts/izsynth
jin
Posts: 62
Joined: Thursday 18 September 2014 20:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: izSynth: make domoticz talk with many TTS engines in a easy way

Post by jin »

toreandre wrote:

Code: Select all

osmc@osmcsoverom:~/domoticz$ ls -al scripts/izsynth
-rwxrwxrwx 1 osmc osmc 41084 Apr 28 19:03 scripts/izsynth
Domoticz is also running under the user "osmc"
mmmm.... your config is right...

I tested creating a "Virtual Button" of type "Selector Switch" and adding the following example:
domoticz02.png
domoticz02.png (38.28 KiB) Viewed 4342 times
and the logs show this:

Code: Select all

2016-05-03 23:30:43.958 User: Admin initiated a switch command
2016-05-03 23:30:43.959 (Dummy) Light/Switch (Selector)
2016-05-03 23:30:44.348 Executing script: /home/pi/domoticz/scripts/izsynth
2016-05-03 23:30:47.443 User: Admin initiated a switch command
2016-05-03 23:30:47.444 (Dummy) Light/Switch (Selector)
2016-05-03 23:30:47.833 Executing script: /home/pi/domoticz/scripts/izsynth
2016-05-03 23:30:50.828 User: Admin initiated a switch command
2016-05-03 23:30:50.830 (Dummy) Light/Switch (Selector)
2016-05-03 23:30:51.326 Executing script: /home/pi/domoticz/scripts/izsynth
2016-05-03 23:30:54.643 User: Admin initiated a switch command
2016-05-03 23:30:54.645 (Dummy) Light/Switch (Selector)
2016-05-03 23:30:55.569 Executing script: /home/pi/domoticz/scripts/izsynth
But the script works perfectly and I can hear the voice when I activate the button...

can you try putting the full path of the script? like:

Code: Select all

script:///home/osmc/domoticz/scripts/izsynth test
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest