Search code examples
javascriptphptext-to-speech

How to text-to-speech a PHP table


I'm working on a project where I have a table containing a list of students, I want my web-app to "say" their name and last names one by one, the same as when a teacher is marking who's present or not.

I dont know if the technology to go to in this situation is Javascript or PHP, although it looks like Javascript might be easier.

Here is the code for the table display, and I thank you all in advance :

 <?php
    if (isset($_GET['datepick']) & isset($_GET['classpick'])) {
        $datepicked = $_GET['datepick'];
        $matierepicked =  $_GET['classpick'];
        $viewab = $conn->prepare("SELECT * FROM absence,etudiant WHERE absence.date = ? AND absence.matiere = ? AND (absence.etudiant_ID = etudiant.etudiant_ID)");
        $viewab->execute(array($datepicked, $matierepicked));

        if ($viewab->rowCount()!=0){


        echo("<table class='table table-condensed table-hover table-bordered table-striped' style='background-color: white'>");
        echo "<tr>";
        echo "<th style='background-color: grey'> Nom </th>";
        echo "<th style='background-color: grey'>Prenom </th>";
        echo "<th style='background-color: grey'>Matiere</th>";
        echo "<th style='background-color: grey'>Date</th>";
        echo "<th style='background-color: grey'>Total des heures absentées</th>";
        echo "</tr>";
        while ($row = $viewab->fetch(PDO::FETCH_ASSOC)) {
            echo "<tr>";
            echo "<td>" . $row['Nom'] . "</td>";
            echo "<td>" . $row['Prenom'] . "</td>";
            echo "<td>" . $row['matiere'] . "</td>";
            echo "<td>" . $row['date'] . "</td>";
            echo "<td>" . $row['Nb_absences'] . "</td>";
            echo "</tr>";
        }
        echo("</table>"); }

Solution

  • Javascript will be easier, for example:

    var msg = new SpeechSynthesisUtterance();
    msg.text = "Hello World";
    window.speechSynthesis.speak(msg);