text to speech freetts in struts2

214 views Asked by At

Hello please help I have done a text to speech java application using free tts now I'm trying to do the same thing with struts 2. I created a button in my table the idea is that when I click the button I'll invoke a struts action called pronounce that extends the freetts class which will read my table's content but I have no idea how to do that this is my old free tts class

package com.hello;

import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
 
public class myfreetts {
 

 private String text; // string to speech
 Voice voice;

 
 public Prononcer(String text) {
  this.text = text;
 }
 
 public void execute() {
 
  System.setProperty("mbrola.base", "C:\\Users\\iup\\workspace\\newpro\\mbrola");
  VoiceManager voiceManager = VoiceManager.getInstance();
  voice = voiceManager.getVoice("mbrola_en1");
  voice.allocate();
  voice.speak(text);
 }
 
 public static void main(String[] args) {
  String text = "FreeTTS was written by the Sun Microsystems Laboratories "
    + "Speech Team and is based on CMU's Flite engine.";
  myfreetts freeTTS = new myfreetts(text);
  freeTTS.execute();
 }
}

and this is my jsp page

<%@ page language="java" contentType="text/html; charset=UTF-8"
 pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
 

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">




<title>profile success</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>


$(document).ready(function(){
    $("#p").click(function(){
       alert("Le bouton a été cliqué.");
    });
});
</script>
</head>
  <body background="images\25.jpg"> 
  

<div style="text-align: center"> <div style="color:WHITE"> <h1> Les informations de votre commande  </h1></div></div>
<hr/> 


<table border="2">
    

    
       <tr>
           <td><div style="color:cc9999"><h3>No_commande               </h3> </div></td>
                 <td><div style="color:cc9999"><h3>Nom                               </h3> </div></td>
                 <td><div style="color:cc9999"><h3>Date                               </h3> </div></td>
                 <td><div style="color:cc9999"><h3>Etat                               </h3> </div></td>
                 <td><div style="color:cc9999"><h3>Tel                                 </h3> </div></td>
                  <td><div style="color:cc9999"><h3>Prononcer                               </h3> </div></td>
                   <td><div style="color:cc9999"><h3>Test                            </h3> </div></td>
   </tr>
   <s:iterator value="list" id="message">
      <tr>
   <td><div style="color:WHITE"><h3> <s:property value="no_commande"/></h3> </div></td>
                 <td><div style="color:WHITE"><h3><s:property value="nom_client"/></h3> </div></td>
                 <td><div style="color:WHITE"><h3><s:property value="date"/></h3> </div></td>
                 <td><div style="color:WHITE"><h3><s:property value="etat"/></h3> </div></td>
                 <td><div style="color:WHITE"><h3><s:property value="tel"/></h3> </div></td>
                 <td><div style="color:WHITE"><h3><button id="p">Cliquez ici</button>
                  <td><div style="color:WHITE"><h3><a href="prononce">test</a> </h3> </div></td>
</h3> </div></td>
   </tr>
    </s:iterator>

</table>



</body>
</html>

ps:I'm still testing the button thats why I used alert and this is my struts.xml

<?xml version="1.0" encoding="UTF-8"?>

 

<!DOCTYPE struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>

    <constant name="struts.devMode" value="false" />   
    <constant name="struts.enable.DynamicMethodInvocation" value="true"/>
     <package name="default" namespace="/" extends="struts-default">

<action name="login">  
<result >login.jsp</result>  
</action>  
  
<action name="loginprocess" class="com.hello.Login" method="execute">
<result name="success"  >loginsucces.jsp</result>  
<result name="error" >loginerror.jsp</result>  
</action>  
  
<action name="logout" class="com.hello.Login" method="logout">  
<result name="success" >logoutsuccess.jsp</result>  
</action>  
  
<action name="profile" class="com.hello.Profile">  
<result name="success" >profilesuccess.jsp</result>  
<result name="error" >profileerror.jsp</result>  
</action>  
  <action name="loginprocess" class="com.hello.Login" method="execute">
<result name="success"  >loginsucces.jsp</result>  
<result name="error" >loginerror.jsp</result>  
</action> 

<action name="viewrecords" class="com.hello.RetrieveRecords">  
<result name="success">viewrecords.jsp</result>  
</action>  
<action name="prononce" class="com.hello.myfreetts">
<result>test.jsp</result>
</action>  
 
 

    </package>

</struts>

Please help I'm desperate.

0

There are 0 answers