mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
98_Text2Speech: Google fixed, svox-pico added
git-svn-id: https://svn.fhem.de/fhem/trunk@9758 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f162920f0d
commit
2a201efbcc
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- bugfix 98_Text2Speech: Google fixed, svox-pico added
|
||||||
- bugfix 00_SIGNALduino: Updated Firmware (3.8.1-HF1)
|
- bugfix 00_SIGNALduino: Updated Firmware (3.8.1-HF1)
|
||||||
fixed send raw
|
fixed send raw
|
||||||
- updated: 74_AMAD: New Mijor Release 0.8.1
|
- updated: 74_AMAD: New Mijor Release 0.8.1
|
||||||
|
@ -73,7 +73,8 @@ my %ttsQuality = ("Google" => "",
|
|||||||
"VoiceRSS" => "f="
|
"VoiceRSS" => "f="
|
||||||
);
|
);
|
||||||
my %ttsMaxChar = ("Google" => 100,
|
my %ttsMaxChar = ("Google" => 100,
|
||||||
"VoiceRSS" => 300
|
"VoiceRSS" => 300,
|
||||||
|
"SVOX-pico" => 1000
|
||||||
);
|
);
|
||||||
my %language = ("Google" => {"Deutsch" => "de",
|
my %language = ("Google" => {"Deutsch" => "de",
|
||||||
"English-US" => "en-us",
|
"English-US" => "en-us",
|
||||||
@ -94,6 +95,16 @@ my %language = ("Google" => {"Deutsch" => "de",
|
|||||||
"Spain" => "es-es",
|
"Spain" => "es-es",
|
||||||
"Italian" => "it-it",
|
"Italian" => "it-it",
|
||||||
"Chinese" => "zh-cn"
|
"Chinese" => "zh-cn"
|
||||||
|
},
|
||||||
|
"SVOX-pico" => {"Deutsch" => "de-DE",
|
||||||
|
"English-US" => "en-US",
|
||||||
|
"Schwedisch" => "en-US", # gibts nicht
|
||||||
|
"Indian-Hindi" => "en-US", # gibts nicht
|
||||||
|
"Arabic" => "en-US", # gibts nicht
|
||||||
|
"France" => "fr-FR",
|
||||||
|
"Spain" => "es-ES",
|
||||||
|
"Italian" => "it-IT",
|
||||||
|
"Chinese" => "en-US" # gibts nicht
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -109,7 +120,7 @@ sub Text2Speech_Initialize($)
|
|||||||
$hash->{AttrFn} = "Text2Speech_Attr";
|
$hash->{AttrFn} = "Text2Speech_Attr";
|
||||||
$hash->{AttrList} = "disable:0,1".
|
$hash->{AttrList} = "disable:0,1".
|
||||||
" TTS_Delemiter".
|
" TTS_Delemiter".
|
||||||
" TTS_Ressource:ESpeak,". join(",", sort keys %ttsHost).
|
" TTS_Ressource:ESpeak,SVOX-pico,". join(",", sort keys %ttsHost).
|
||||||
" TTS_APIKey".
|
" TTS_APIKey".
|
||||||
" TTS_User".
|
" TTS_User".
|
||||||
" TTS_Quality:".
|
" TTS_Quality:".
|
||||||
@ -412,6 +423,7 @@ sub Text2Speech_Set($@)
|
|||||||
return undef if(AttrVal($hash->{NAME}, "disable", "0") eq "1");
|
return undef if(AttrVal($hash->{NAME}, "disable", "0") eq "1");
|
||||||
|
|
||||||
if($cmd eq "tts") {
|
if($cmd eq "tts") {
|
||||||
|
readingsSingleUpdate($hash, "playing", "1", 1);
|
||||||
if($hash->{MODE} eq "DIRECT") {
|
if($hash->{MODE} eq "DIRECT") {
|
||||||
Text2Speech_PrepareSpeech($hash, join(" ", @a));
|
Text2Speech_PrepareSpeech($hash, join(" ", @a));
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("Text2Speech_DoIt", $hash, "Text2Speech_Done", $TTS_TimeOut, "Text2Speech_AbortFn", $hash) unless(exists($hash->{helper}{RUNNING_PID}));
|
$hash->{helper}{RUNNING_PID} = BlockingCall("Text2Speech_DoIt", $hash, "Text2Speech_Done", $TTS_TimeOut, "Text2Speech_AbortFn", $hash) unless(exists($hash->{helper}{RUNNING_PID}));
|
||||||
@ -470,7 +482,6 @@ sub Text2Speech_PrepareSpeech($$) {
|
|||||||
$TTS_AddDelemiter = "";
|
$TTS_AddDelemiter = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($TTS_Ressource ne "ESpeak") {
|
|
||||||
my @text;
|
my @text;
|
||||||
|
|
||||||
# ersetze Sonderzeichen die Google nicht auflösen kann
|
# ersetze Sonderzeichen die Google nicht auflösen kann
|
||||||
@ -533,10 +544,6 @@ sub Text2Speech_PrepareSpeech($$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@{$hash->{helper}{Text2Speech}} = @text;
|
@{$hash->{helper}{Text2Speech}} = @text;
|
||||||
|
|
||||||
} else {
|
|
||||||
push(@{$hash->{helper}{Text2Speech}}, $t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -650,7 +657,7 @@ sub Text2Speech_CalcMP3Duration($$) {
|
|||||||
# param2: string: Dateiname
|
# param2: string: Dateiname
|
||||||
# param2: string: Text
|
# param2: string: Text
|
||||||
#
|
#
|
||||||
# Holt den Text aus dem Google Translator als MP3Datei
|
# Holt den Text mithilfe der entsprechenden TTS_Ressource
|
||||||
#####################################
|
#####################################
|
||||||
sub Text2Speech_Download($$$) {
|
sub Text2Speech_Download($$$) {
|
||||||
my ($hash, $file, $text) = @_;
|
my ($hash, $file, $text) = @_;
|
||||||
@ -661,8 +668,9 @@ sub Text2Speech_Download($$$) {
|
|||||||
my $TTS_Language = AttrVal($hash->{NAME}, "TTS_Language", "Deutsch");
|
my $TTS_Language = AttrVal($hash->{NAME}, "TTS_Language", "Deutsch");
|
||||||
my $TTS_Quality = AttrVal($hash->{NAME}, "TTS_Quality", "");
|
my $TTS_Quality = AttrVal($hash->{NAME}, "TTS_Quality", "");
|
||||||
my $TTS_Speed = AttrVal($hash->{NAME}, "TTS_Speed", "");
|
my $TTS_Speed = AttrVal($hash->{NAME}, "TTS_Speed", "");
|
||||||
|
my $cmd;
|
||||||
|
|
||||||
|
if($TTS_Ressource =~ m/(Google|VoiceRSS)/) {
|
||||||
my $HttpResponse;
|
my $HttpResponse;
|
||||||
my $HttpResponseErr;
|
my $HttpResponseErr;
|
||||||
my $fh;
|
my $fh;
|
||||||
@ -705,6 +713,29 @@ sub Text2Speech_Download($$$) {
|
|||||||
$fh->print($HttpResponse);
|
$fh->print($HttpResponse);
|
||||||
Log3 $hash->{NAME}, 4, "Text2Speech: Schreibe mp3 in die Datei $file mit ".length($HttpResponse)." Bytes";
|
Log3 $hash->{NAME}, 4, "Text2Speech: Schreibe mp3 in die Datei $file mit ".length($HttpResponse)." Bytes";
|
||||||
close($fh);
|
close($fh);
|
||||||
|
} elsif ($TTS_Ressource eq "ESpeak") {
|
||||||
|
my $FileWav = $file . ".wav";
|
||||||
|
|
||||||
|
$cmd = "sudo espeak -vde+f3 -k5 -s150 \"" . $text . "\">\"" . $FileWav . "\"";
|
||||||
|
Log3 $hash, 4, "Text2Speech:" .$cmd;
|
||||||
|
system($cmd);
|
||||||
|
|
||||||
|
$cmd = "lame \"" . $FileWav . "\" \"" . $file . "\"";
|
||||||
|
Log3 $hash, 4, "Text2Speech:" .$cmd;
|
||||||
|
system($cmd);
|
||||||
|
unlink $FileWav;
|
||||||
|
} elsif ($TTS_Ressource eq "SVOX-pico") {
|
||||||
|
my $FileWav = $file . ".wav";
|
||||||
|
|
||||||
|
$cmd = "pico2wave --lang=" . $language{$TTS_Ressource}{$TTS_Language} . " --wave=\"" . $FileWav . "\" \"" . $text . "\"";
|
||||||
|
Log3 $hash, 4, "Text2Speech:" .$cmd;
|
||||||
|
system($cmd);
|
||||||
|
|
||||||
|
$cmd = "lame \"" . $FileWav . "\" \"" . $file . "\"";
|
||||||
|
Log3 $hash, 4, "Text2Speech:" .$cmd;
|
||||||
|
system($cmd);
|
||||||
|
unlink $FileWav;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -725,8 +756,6 @@ sub Text2Speech_DoIt($) {
|
|||||||
|
|
||||||
Log3 $hash->{NAME}, 4, "Verwende TTS Spracheinstellung: ".$TTS_Language;
|
Log3 $hash->{NAME}, 4, "Verwende TTS Spracheinstellung: ".$TTS_Language;
|
||||||
|
|
||||||
if($TTS_Ressource =~ m/(Google|VoiceRSS)/) {
|
|
||||||
|
|
||||||
my $filename;
|
my $filename;
|
||||||
my $file;
|
my $file;
|
||||||
|
|
||||||
@ -736,7 +765,6 @@ sub Text2Speech_DoIt($) {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(AttrVal($hash->{NAME}, "TTS_UseMP3Wrap", 0)) {
|
if(AttrVal($hash->{NAME}, "TTS_UseMP3Wrap", 0)) {
|
||||||
# benutze das Tool MP3Wrap um bereits einzelne vorhandene Sprachdateien
|
# benutze das Tool MP3Wrap um bereits einzelne vorhandene Sprachdateien
|
||||||
# zusammenzuführen. Ziel: sauberer Sprachfluss
|
# zusammenzuführen. Ziel: sauberer Sprachfluss
|
||||||
@ -820,16 +848,6 @@ sub Text2Speech_DoIt($) {
|
|||||||
return $hash->{NAME}. "|".
|
return $hash->{NAME}. "|".
|
||||||
"1" ."|".
|
"1" ."|".
|
||||||
$file;
|
$file;
|
||||||
|
|
||||||
} elsif ($TTS_Ressource eq "ESpeak") {
|
|
||||||
$cmd = "sudo espeak -vde+f3 -k5 -s150 \"" . $hash->{helper}{Text2Speech}[0] . "\"";
|
|
||||||
Log3 $hash, 4, "Text2Speech:" .$cmd;
|
|
||||||
system($cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $hash->{NAME}. "|".
|
|
||||||
"1" ."|".
|
|
||||||
"";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
@ -863,6 +881,8 @@ sub Text2Speech_Done($) {
|
|||||||
# erneutes aufrufen da ev. weiterer Text in der Warteschlange steht
|
# erneutes aufrufen da ev. weiterer Text in der Warteschlange steht
|
||||||
if(@{$hash->{helper}{Text2Speech}} > 0) {
|
if(@{$hash->{helper}{Text2Speech}} > 0) {
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("Text2Speech_DoIt", $hash, "Text2Speech_Done", $TTS_TimeOut, "Text2Speech_AbortFn", $hash);
|
$hash->{helper}{RUNNING_PID} = BlockingCall("Text2Speech_DoIt", $hash, "Text2Speech_Done", $TTS_TimeOut, "Text2Speech_AbortFn", $hash);
|
||||||
|
} else {
|
||||||
|
readingsSingleUpdate($hash, "playing", "0", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,8 +1032,19 @@ sub Text2Speech_WriteStats($$$$){
|
|||||||
because the quality is also fantastic. To use this engine you need an APIKey (see TTS_APIKey)
|
because the quality is also fantastic. To use this engine you need an APIKey (see TTS_APIKey)
|
||||||
</li>
|
</li>
|
||||||
<li>ESpeak<br>
|
<li>ESpeak<br>
|
||||||
Using the ESpeak Engine. Installation of the espeak sourcen is required.<br>
|
Using the ESpeak Engine. Installation Espeak and lame is required.<br>
|
||||||
<code>apt-get install espeak</code>
|
<code>apt-get install espeak lame</code>
|
||||||
|
</li>
|
||||||
|
<li>SVOX-pico<br>
|
||||||
|
Using the SVOX-Pico TTS-Engine (from the AOSP).<br>
|
||||||
|
Installation of the engine and <code>lame</code> is required:<br>
|
||||||
|
<code>sudo apt-get install libttspico-utils lame</code><br><br>
|
||||||
|
On ARM/Raspbian the package <code>libttspico-utils</code>,<br>
|
||||||
|
so you may have to compile it yourself or use the precompiled package from <a target="_blank" href"http://www.robotnet.de/2014/03/20/sprich-freund-und-tritt-ein-sprachausgabe-fur-den-rasberry-pi/">this guide</a>, in short:<br>
|
||||||
|
<code>sudo apt-get install libpopt-dev lame</code><br>
|
||||||
|
<code>cd /tmp</code><br>
|
||||||
|
<code>wget http://www.dr-bischoff.de/raspi/pico2wave.deb</code><br>
|
||||||
|
<code>sudo dpkg --install pico2wave.deb</code>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@ -1199,8 +1230,19 @@ sub Text2Speech_WriteStats($$$$){
|
|||||||
</li>
|
</li>
|
||||||
<li>ESpeak<br>
|
<li>ESpeak<br>
|
||||||
Nutzung der ESpeak Offline Sprachengine. Die Qualitä ist schlechter als die Google Engine.
|
Nutzung der ESpeak Offline Sprachengine. Die Qualitä ist schlechter als die Google Engine.
|
||||||
ESpeak ist vor der Nutzung zu installieren.<br>
|
ESpeak und lame sind vor der Nutzung zu installieren.<br>
|
||||||
<code>apt-get install espeak</code>
|
<code>apt-get install espeak lame</code>
|
||||||
|
</li>
|
||||||
|
<li>SVOX-pico<br>
|
||||||
|
Nutzung der SVOX-Pico TTS-Engine (aus dem AOSP).<br>
|
||||||
|
Die Sprachengine sowie <code>lame</code> müssen installiert sein:<br>
|
||||||
|
<code>sudo apt-get install libttspico-utils lame</code><br><br>
|
||||||
|
Für ARM/Raspbian sind die <code>libttspico-utils</code> leider nicht verfügbar,<br>
|
||||||
|
deswegen müsste man diese selbst kompilieren oder das vorkompilierte Paket aus <a target="_blank" href"http://www.robotnet.de/2014/03/20/sprich-freund-und-tritt-ein-sprachausgabe-fur-den-rasberry-pi/">dieser Anleitung</a> verwenden, in aller Kürze:<br>
|
||||||
|
<code>sudo apt-get install libpopt-dev lame</code><br>
|
||||||
|
<code>cd /tmp</code><br>
|
||||||
|
<code>wget http://www.dr-bischoff.de/raspi/pico2wave.deb</code><br>
|
||||||
|
<code>sudo dpkg --install pico2wave.deb</code>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@ -1263,7 +1305,8 @@ sub Text2Speech_WriteStats($$$$){
|
|||||||
<code>attr myTTS TTS_VolumeAdjust 400</code><br>
|
<code>attr myTTS TTS_VolumeAdjust 400</code><br>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li><a href="#readingFnAttributes">readingFnAttributes</a></li><br>
|
<li><a href="#readingFnAttributes">readingFnAttributes</a>
|
||||||
|
</li><br>
|
||||||
|
|
||||||
<li><a href="#disable">disable</a><br>
|
<li><a href="#disable">disable</a><br>
|
||||||
If this attribute is activated, the soundoutput will be disabled.<br>
|
If this attribute is activated, the soundoutput will be disabled.<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user