2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

98_Text2Speech.pm: fix a problem with microseconds in time()

by using mp3-templates or playing mp3 directly


git-svn-id: https://svn.fhem.de/fhem/trunk@6493 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
tobiasfaust 2014-09-01 08:57:43 +00:00
parent c9af6363ef
commit 8ecd570718
2 changed files with 12 additions and 3 deletions

View File

@ -1,5 +1,7 @@
# 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.
- change: 98_Text2Speech.pm: fix a problem with microseconds in time()
by using mp3-templates or playing mp3 directly
- feature: state definition and split attribute added to 66_ECMD, - feature: state definition and split attribute added to 66_ECMD,
67_ECMDDevice 67_ECMDDevice
- FHEMWEB: JavaScripts and CssFiles attributes added - FHEMWEB: JavaScripts and CssFiles attributes added

View File

@ -386,7 +386,9 @@ sub Text2Speech_PrepareSpeech($$) {
for(my $i=0; $i<(@text); $i++) { for(my $i=0; $i<(@text); $i++) {
@FileTplPc = ($text[$i] =~ /:([^:]+):/g); @FileTplPc = ($text[$i] =~ /:([^:]+):/g);
for(my $j=0; $j<(@FileTplPc); $j++) { for(my $j=0; $j<(@FileTplPc); $j++) {
my $tpl = "FileTpl_".time()."_#".$i; #eindeutige Templatedefinition schaffen my $time = time();
$time =~ s/\.//g;
my $tpl = "FileTpl_".$time."_#".$i; #eindeutige Templatedefinition schaffen
Log3 $hash, 4, "$me: Angabe einer direkten MP3-Datei gefunden: $FileTplPc[$i] => $tpl"; Log3 $hash, 4, "$me: Angabe einer direkten MP3-Datei gefunden: $FileTplPc[$i] => $tpl";
push(@FileTpl, $tpl.":".$FileTplPc[$j]); #zb: FileTpl_123645875_#0:/ring.mp3 push(@FileTpl, $tpl.":".$FileTplPc[$j]); #zb: FileTpl_123645875_#0:/ring.mp3
$text[$i] =~ s/$FileTplPc[$j]/$tpl/g; # Ersetze die DateiDefinition gegen ein Template $text[$i] =~ s/$FileTplPc[$j]/$tpl/g; # Ersetze die DateiDefinition gegen ein Template
@ -598,18 +600,23 @@ sub Text2Speech_DoIt($) {
} }
} }
Log3 $hash->{NAME}, 4, "Text2Speech: Bearbeite jetzt den Text: ". $hash->{helper}{Text2Speech}[0];
if(-e $TTS_CacheFileDir."/".$hash->{helper}{Text2Speech}[0]) { if(-e $TTS_CacheFileDir."/".$hash->{helper}{Text2Speech}[0]) {
# falls eine bestimmte mp3-Datei gespielt werden soll # falls eine bestimmte mp3-Datei gespielt werden soll
$filename = $hash->{helper}{Text2Speech}[0]; $filename = $hash->{helper}{Text2Speech}[0];
Log3 $hash->{NAME}, 4, "Text2Speech: $filename als direkte MP3 Datei erkannt!";
} else { } else {
$filename = md5_hex($hash->{helper}{Text2Speech}[0]) . ".mp3"; $filename = md5_hex($hash->{helper}{Text2Speech}[0]) . ".mp3";
Log3 $hash->{NAME}, 4, "Text2Speech: Textbaustein ist keine direkte MP3 Datei, ermittle MD5 CacheNamen: $filename";
} }
$file = $TTS_CacheFileDir."/".$filename; $file = $TTS_CacheFileDir."/".$filename;
Log3 $hash->{NAME}, 4, "Text2Speech: Bearbeite jetzt den Text: ". $hash->{helper}{Text2Speech}[0];
if(! -e $file) { # Datei existiert noch nicht im Cache if(! -e $file) { # Datei existiert noch nicht im Cache
Text2Speech_Download($hash, $file, $hash->{helper}{Text2Speech}[0]); Text2Speech_Download($hash, $file, $hash->{helper}{Text2Speech}[0]);
} else {
Log3 $hash->{NAME}, 4, "Text2Speech: '$file' gefunden, kein Download";
} }
if(-e $file) { # Datei existiert jetzt if(-e $file) { # Datei existiert jetzt