-
-
Save rafaelfreba/a0902af287f508354aa895e1adfa22ce to your computer and use it in GitHub Desktop.
Função de Saudação Falada (bom dia, boa tarde e boa noite)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function saudacaoFalada($nome = ''){ | |
date_default_timezone_set('America/Cuiaba'); | |
$hora = date('H'); | |
if( $hora >= 6 && $hora <= 12 ) | |
$saudacao = 'Bom dia' . (empty($nome) ? '!' : ', ' . $nome); | |
else if ($hora > 12 && $hora <= 18 ) | |
$saudacao = 'Boa tarde' . (empty($nome) ? '!' : ', ' . $nome); | |
else | |
$saudacao = 'Boa noite' . (empty($nome) ? '!' : ', ' . $nome); | |
return "<script>speechSynthesis.speak(new SpeechSynthesisUtterance('$saudacao'));</script>"; | |
} | |
echo saudacaoFalada( 'Danilo' ); | |
// Irá falar conforme o horário: | |
// Bom dia Danilo! | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adicionei a opção de falar a saudação através da Web Speech API. (Funcionando no Edge e Firefox)