ФЭНДОМ


Для выполнения скрипта проговора времени, вам понадобятся еще два скрипта number_case.php и pluralform.php:


А вот и сам скрипт:


stime.php

#!/usr/bin/php
<?php
    // remove + if you don't need it, it slows down rendering
    $request['hour'] = ( 
            isset($argv[1]) 
            && 0 < (int)$argv[1]
            && (int)$argv[1] < 25 
            ) ? (int)$argv[1] : 0;
    $request['minute'] = ( 
            isset($argv[2]) 
            && 0 < (int)$argv[2]
            && (int)$argv[2] < 61 
            ) ? (int)$argv[2] : 0;
    $reply = array();
    $cmdReply = array();
    
    /**
     * requesting hour
     */
    exec("numbers.php male {$request['hour']}", $cmdReply);
    $reply[] = trim(join(" ", $cmdReply));
    $cmdReply = array();
    exec("pluralform.php {$request['hour']} ч+ас час+а час+ов", $cmdReply);
    $reply[] = trim(join(" ", $cmdReply));
    $cmdReply = array();
    /**
     * requesting minute
     */
    exec("numbers.php female {$request['minute']}", $cmdReply);
    $reply[] = trim(join(" ", $cmdReply));
    $cmdReply = array();
    exec("pluralform.php {$request['minute']} мин+ута мин+уты мин+ут", $cmdReply);
    $reply[] = trim(join(" ", $cmdReply));
    $cmdReply = array();
    
    echo trim(join(" ", $reply));
?>

Скрипт выше недоделан, вот вариант на bash


#!/bin/bash
# http://ru.festivalspeaker.wikia.com
SCRIPTS=/home/username/scripts/festival/

stime_H=$(date +%H)
stime_M=$(date +%M)
stime_H=`echo ${stime_H}|sed 's/^0*//'`
stime_M=`echo ${stime_M}|sed 's/^0*//'`
TEXT="Время $(${SCRIPTS}number_case.php male ${stime_H} ) \
      $(${SCRIPTS}pluralform.php ${stime_H} час час+а час+ов)"
if [ ${stime_M} -eq 0 ] ; then
 TEXT="${TEXT} ровно"
else
 TEXT="${TEXT} $(${SCRIPTS}number_case.php female ${stime_M} ) \
      $(${SCRIPTS}pluralform.php ${stime_M} минута минуты минут),"
fi


${SCRIPTS}saytext_ru.sh "$TEXT"

Меняем username на свой логин, даем права выполнения:

$ chmod u+x stime.php say_time.sh

Готово!