Page 1 of 4

Current Conditions Audio

Posted: Tue 20 Sep 2016 12:09 am
by PaulMy
A little script http://www.komokaweather.com/weather/meteo_audio.html (still a work in progress) borrowed from F1LXJ Serge at Météo d'Annoeullin dans les Hauts-de-France http://f1lxj.fr/weather/index.htm and http://www.meteo-saint-brevin.fr/

Enjoying,
Paul

Re: For those with poor eyesight

Posted: Tue 20 Sep 2016 9:24 am
by mcrossley
PaulMy wrote:A little script http://www.komokaweather.com/weather/meteo_audio.html (still a work in progress) borrowed from F1LXJ Serge at Météo d'Annoeullin dans les Hauts-de-France http://f1lxj.free.fr/weather/index.htm and http://www.meteo-saint-brevin.fr/

Enjoying,
Paul
Very good Paul. I think you need to replace the decimal points with the word 'point' though - certainly for UK English is is interpreting the decimal as a full stop and putting a long pause in.
E.g. change "16.3 degrees celsius" to "16 point 3 degrees celsius"

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 1:08 am
by PaulMy
Correct Mark, I noticed that for English and I assume it was not a problem with the original French, but how? It is a webtag processed script.

I had not yet shown the French version as the French accented words did not download correctly but got an update from Serge that I will try.

Paul

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 8:30 am
by mcrossley
If you are creating the 'text' in PHP, then where you use the appropriate tag use a str_replace(). Eg. using made up variables...

Code: Select all

$text = "The temperature is $temp degrees celsius"
to...
$text = 'The temperature is ' . str_replace('.', ' point ', $temp) . ' degrees celsius';
edit: Though the ' point ' string would be better as a variable then you can localise it easily.

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 10:45 am
by mlj1
Hi Paul and everybody,

Thank you for your interrest for our weather audio pages.
After trying poor quality mp3 audio messages generators, I found responsivevoice and tried their API with Serge F1LXJ.

It is by far the best quality audio obtained right now, but our audio pages need the responsivevoice website to be up in order to work, since the script use to call routines on it. We allready got an issue for a few days when their website was down.

Your help will be appreciated to provide us well formated English sentences with the right words. And for the time and data formats as well.
We will follow your work with interrest.

Note the French Female voice is excellent on a Windows PC but a little agressive on Ipad or Iphone.

http://www.meteo-saint-brevin.fr/audio.htm
http://www.meteo-saint-brevin.fr/infos.htm
Best regards,
Marcel

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 11:12 am
by mcrossley
Paul, there is lots you could around this to make it more 'human' :roll: , for instance...

Code: Select all

if ($sunshine == 0) {
	$text += "There has been no sunshine so far today.\n";
} else {
	$text += "The sun shine so far today is " . str_replace('.', ' point ', $sunshine) . " hours.\n";
}
if ($rainfall == 0) {
	$text += "There has been no rainfall so far today.\n";
} else {
	$text += "The rain so far today is " . str_replace('.', ' point ', $rainfall) . " millimeters.\n";
}

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 11:38 am
by mlj1
Hi Mark,

The problem is the actual script is in html and I don't know how to convert it in PHP to apply the suggestions you gave to Paul.
Best regards

Code: Select all

<body>
<h3><img src='favicon.ico'>&nbsp;M&eacute;t&eacute;o Saint-Brevin - Bulletins audio</h3><hr><br>
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<center>
<img src="images/grundig512.jpg"><br /><br>

<textarea id="text" style="height:1px;display:none;">
Voici les derniers relevés de Météo Saint-Brévin. 
Effectués le <#time format="dddd d mmmm"> à <#time format="h'h'nn">. 
La température est de <#temp> degrés avec un ressenti de <#apptemp> degrés. 
Le taux d'humidité est de <#hum> pour 100. 
La pression atmosphérique est de <#press> hecto pascals; et la tendance barométrique est : "<#presstrend>". 
Le vent venait du secteur <#currentwdir>. à une vitesse de <#wlatest> kilomètres par heure. 
La plus forte rafale du jour était de <#wgustTM> kilomètres par heure, à <#TwgustTM format="h'H'nn">. 
La base théorique des nuages se situe, à : <#cloudbase>.
Le nivau de pluie du jour est de <#rfall> millimètres par mètre carré. 
Lever du soleil aujourd'hui à <#sunrise format="h'h'n">. Et coucher du soleil à <#sunset format="h'h'n">.
Merci pour votre attention.
Le prochain bulletin sera disponible dans quelques minutes.</textarea>
</textarea>

<textarea id="text1" style="height:1px;display:none;">
Here is the latest weather report from Meteo Saint-Brevin.
Released today at <#time format="h' 'nn">.
Temperature is <#temp>° celsius, feeling like <#apptemp>°. 
It was <#temptrendenglish> over the last three hours.
Humidity is <#hum> %.
The atmospheric pressure is <#press> hectopascals;
And barometric pressure trend is : "<#presstrendenglish>" .
The wind is blowing from a bearing of <#bearing>°; with a speed of <#wlatest> Km/h.
And the strongest gust today was <#wgustTM> Km/h at <#TwgustTM format="h' 'nn">.
The theorical cloud base is : <#cloudbase>.
The rain level today is <#rfall> millimeter per square meter.
Actually, the Davis station forecast shows : <#wsforecast>. 
Sunrise today at <#sunrise format="h' 'n">, and sunset at <#sunset format="h' 'n">.
Thank you for your attention.
The next report will be available in a few minutes.
</textarea>

<input
  onclick="responsiveVoice.speak($('#text').val(), 'French Female');"
  type="button"
  value="Cliquez ici pour écouter le dernier bulletin de Météo Saint-Brevin"
/> 
<p></p>
<input
  onclick="responsiveVoice.speak($('#text1').val(), 'US English Male');"
  type="button"
  value="Click here to listen to the latest report from Météo Saint-Brevin"
/>
</body>

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 4:17 pm
by mcrossley
Ah, if you don't have PHP then it is a little more complex. You will have to put the variables into some javascript and get that to generate the final text in the clients browser. Something like this (untested - only the English is done, my French isn't that good!)...

Code: Select all

<body>
<h3><img src='favicon.ico'>&nbsp;M&eacute;t&eacute;o Saint-Brevin - Bulletins audio</h3><hr><br>
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<center>
<img src="images/grundig512.jpg"><br /><br>

<textarea id="text" style="height:1px;display:none;">
Voici les derniers relevés de Météo Saint-Brévin. 
Effectués le <#time format="dddd d mmmm"> à <#time format="h'h'nn">. 
La température est de <#temp> degrés avec un ressenti de <#apptemp> degrés. 
Le taux d'humidité est de <#hum> pour 100. 
La pression atmosphérique est de <#press> hecto pascals; et la tendance barométrique est : "<#presstrend>". 
Le vent venait du secteur <#currentwdir>. à une vitesse de <#wlatest> kilomètres par heure. 
La plus forte rafale du jour était de <#wgustTM> kilomètres par heure, à <#TwgustTM format="h'H'nn">. 
La base théorique des nuages se situe, à : <#cloudbase>.
Le nivau de pluie du jour est de <#rfall> millimètres par mètre carré. 
Lever du soleil aujourd'hui à <#sunrise format="h'h'n">. Et coucher du soleil à <#sunset format="h'h'n">.
Merci pour votre attention.
Le prochain bulletin sera disponible dans quelques minutes.
</textarea>

<textarea id="text1" style="height:1px;display:none;"></textarea>

<input
  onclick="responsiveVoice.speak($('#text').val(), 'French Female');"
  type="button"
  value="Cliquez ici pour écouter le dernier bulletin de Météo Saint-Brevin"
/> 
<p></p>
<input
  onclick="responsiveVoice.speak($('#text1').val(), 'US English Male');"
  type="button"
  value="Click here to listen to the latest report from Météo Saint-Brevin"
/>
<script>
var text1 = 'Here is the latest weather report from Meteo Saint-Brevin. Released today at <#time format="h' 'nn">. ';
text1 += 'The temperature is ' + (<#temp> % 1 == 0 ? parseInt(<#temp>) : <#temp>) + '° Celsius, feeling like (<#apptemp> % 1 == 0 ? parseInt(<#apptemp> : <#apptemp>) + '°. '; 
text1 += 'The temperature has been <#temptrendenglish> over the last three hours. ';
text1 += 'Humidity is <#hum> %. ';
text1 += 'The atmospheric pressure is <#press> hectopascals; ';
text1 += 'And the pressure trend is <#presstrendenglish>. ';
if (<#wlatest> == 0) {
    text1 += 'The wind is currently calm. ';
} else {
    text1 += 'The wind is blowing from a bearing of <#bearing>°; with a speed of ' + (<#wlatest> % 1 == 0 ? parseInt(<#wlatest>) : <#wlatest>) + ' Km/h. ';
}
text1 += 'And the strongest gust today was ' + (<#wgustTM> % 1 == 0 ? parseInt(<#wgustTM>) : <#wgustTM>) + ' Km/h at <#TwgustTM format="h' 'nn">. ';
text1 += 'The theorical cloud base is : <#cloudbase>. ';
if (<#rfall> == 0) {
    text1 += 'It has not rained so far today. ';
} else {
    text1 += 'The rainfall today is ' + (<#rfall> % 1 == 0 ? parseInt(<#rfall>) : <#rfall>) + ' millimetres. ';
}
text1 += 'The Davis station forecast shows : <#wsforecast>. ';
text1 += 'Sunrise today at <#sunrise format="h' 'n">, and sunset at <#sunset format="h' 'n">. ';'
text1 += 'Thank you for your attention. ';
text1 += 'The next report will be available in a few minutes.';
document.getElementById('text1').innerText = text1;
</script>
</body>

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 4:32 pm
by mlj1
Thank you very much Mark !
I will try that as soon as possible.
Will it be possible in the English part of that script to include some code in form of strreplace to replace the decimal point in a value by the word point (ie 21 point 2 degrees in place of 21.2 degrees) ?

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 5:04 pm
by mlj1
Really sorry Mark !
I copied your script in a test page here
http://www.meteo-saint-brevin.fr/voice/audio.htm
and unfortunately, the button for English message gives no sound.
Could you please have a look and tell me what I did wrong ?
Thank you in advance

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 5:10 pm
by mcrossley
Hi Marcel, it looks like Cumulus hasn't processed the page - it still has the web tags in it.

I'll look at doing the 'point' stuff...

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 5:35 pm
by mcrossley
And there was at least one error in the code before, still untested, but looks better to my eye.
Just the script this time...

Code: Select all

var text1 = 'Here is the latest weather report from Meteo Saint-Brevin. Released today at <#time format="h' 'nn">. ';
var english = {};
var point = ' point ';
english.temp = replacePoint(<#temp>, point);
english.apptemp = replacePoint(<#apptemp>, point);
english.wlatest = replacePoint(<#wlatest>, point);
english.wgustTM = replacePoint(<#wgustTM>, point);
english.rfall = replacePoint(<#rfall>, point);

text1 += 'The temperature is ' + english.temp + '° Celsius, feeling like ' + english.apptemp + '°. ';
text1 += 'The temperature has been <#temptrendenglish> over the last three hours. ';
text1 += 'Humidity is <#hum> %. ';
text1 += 'The atmospheric pressure is <#press> hectopascals; ';
text1 += 'And the pressure trend is <#presstrendenglish>. ';
if (<#wlatest> == 0) {
    text1 += 'The wind is currently calm. ';
} else {
    text1 += 'The wind is blowing from a bearing of <#bearing>°; with a speed of ' + english.wlatest + ' Km/h. ';
}
text1 += 'And the strongest gust today was ' + english.wgustTM + ' Km/h at <#TwgustTM format="h' 'nn">. ';
text1 += 'The theorical cloud base is : <#cloudbase>. ';
if (<#rfall> == 0) {
    text1 += 'It has not rained so far today. ';
} else {
    text1 += 'The rainfall today is ' + english.rfall + ' millimetres. ';
}
text1 += 'The Davis station forecast shows : <#wsforecast>. ';
text1 += 'Sunrise today at <#sunrise format="h' 'n">, and sunset at <#sunset format="h' 'n">. ';
text1 += 'Thank you for your attention. ';
text1 += 'The next report will be available in a few minutes.';

document.getElementById('text1').innerText = text1;

function replacePoint(val, str) {
    return (val % 1 === 0 ? parseInt(val) : val).toString().replace('.', str);
}

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 6:00 pm
by PaulMy
I wish I could participate in the testing learning but not at home for a few more hours... I will give it a try then.

Paul

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 8:11 pm
by mlj1
Thank you Mike
Sorry for my mistake in a previous script which was not processed by Cumulus. Ooooops !
After correcting the issue, the button did not give the message in English in the loudspeaker.
After insterting your last script, it speaks now.
As you will listen by visiting
http://www.meteo-saint-brevin.fr/audio.htm
the temperatures and maximum gust are truncated.
It does not say 21 point 7 degrees but 21 degrees.
On an other hand, i would appreciate to have the barometric pressure truncated (1013 hPa instead of 1013,47 hPa)
All in your script is new for me and I enjoy learning.
Thanks again

Re: For those with poor eyesight

Posted: Wed 21 Sep 2016 9:16 pm
by Mapantz
Really like this!

The male voice reminds me of the shipping forecast we have in the UK: https://youtu.be/oguCxlZ94Ho?t=119