IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Java Discussion :

HTTPClient java et Serveur de reconnaissance vocale


Sujet :

Java

  1. #1
    Membre du Club
    Homme Profil pro
    Architecte réseau
    Inscrit en
    Juillet 2011
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Architecte réseau
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2011
    Messages : 43
    Points : 43
    Points
    43
    Par défaut HTTPClient java et Serveur de reconnaissance vocale
    Bonjour.

    J'ai un programme java ( open source) qui fait la reconnaissance vocale et qui utilise L’API JavaSpeech et comme "Engine" ou Moteur le CloudGarden (pas Gratuit pour les entreprises) et je veux exécuter ce code sur un serveur d'une entreprise qui qui fait de la reconnaissance vocale (http://www.developpez.net/forums/new...newthread&f=22) (je les ai contacté et on m'a donné un identifiant et une clé pour pourvoir se connecter à leur serveur pour exécuter tout code de reconnaissance vocale . Voici le code java pour la reconnaissance vocale:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
     
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.speech.*;
    import javax.speech.recognition.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.datatransfer.Clipboard;
    import java.awt.datatransfer.StringSelection;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
     
    public class ReconVocale2 {
    	public static void main(String []args) throws Exception{
    		Moteur2 moteur = new Moteur2();
    	}
    }
     
    class Moteur2 extends ResultAdapter implements RecognizerListener, ActionListener{
    	public Moteur2() throws Exception{
    		bc = new BrowserControl();
    		//**Interface graphique**//
    		fen = new Fenetre();
    		fen.setVisible(true);
    		//**Interface graphique**//
     
    		//**Ecouteur de la boite combo**//
    		fen.combo.addActionListener(this);
    		//**Ecouteur de la boite combo**//
     
    		//**Ecouteur du bouton Pause**//
    		fen.pause.addMouseListener(new MouseAdapter(){
    			public void mouseClicked(MouseEvent ev){
    				rec.pause();
    				try {
    					rec.waitEngineState(rec.PAUSED);
    				} 
    				catch (Exception e) {
    					// TODO Auto-generated catch block
    					e.printStackTrace();
    				}
    				JOptionPane.showMessageDialog(null, "Pause");
    			}
    		});
    		//**Ecouteur du bouton pause**//
     
    		//**Ecouteur du bouton resume**//
    		fen.ecoute.addMouseListener(new MouseAdapter(){
    			public void mouseClicked(MouseEvent ev){
    				try {
    					rec.resume();
    					rec.waitEngineState(rec.RESUMED);
    				} 
    				catch (Exception e) {
    					// TODO Auto-generated catch block
    					e.printStackTrace();
    				}
    				JOptionPane.showMessageDialog(null, "Ecoute");
    			}
    		});
    		//**Ecouteur du bouton resume**//
     
    		//**Test moteurs disponibles**//
    		EngineList list = Central.availableRecognizers(null);
    		//System.out.println("Num of recos = "+list.size());
    		Object liste[] = list.toArray();
    		for(int i = 0; i<liste.length; i++)
    			System.out.println(liste[i]);
    		//**Test moteurs disponibles**//
     
    		//**Description du moteur**//
    		RecognizerModeDesc required = (RecognizerModeDesc) liste[0];
    		required.setRunning(true);
    		System.out.println("Profils utilisateurs: "+required.getSpeakerProfiles());
    		System.out.println("Localisation: "+required.getLocale());
    		System.out.println("En fonctionnement? "+required.getRunning());
    		//**Description du moteur**//
     
    		//**Creation du moteur**//
    		rec = Central.createRecognizer(required);
    		System.out.println("Etat du moteur avant allocation: "+rec.getEngineState());
    		//**Creation du moteur**//
     
    		//**Thread pour allocation des ressources au moteur**//
    		new Thread( new Runnable(){
    			public void run(){
    				try{
    				rec.allocate();
    				}
    				catch(Exception e){
     
    				}
    			}
    		}).start();
    		//**Thread pour allocation des ressources au moteur**//
     
    		//**Attente d'allocation**//
    		rec.waitEngineState(rec.ALLOCATED);
    		System.out.println("Etat du moteur apres allocation: "+rec.getEngineState());
    		//**Attente d'allocation**//
     
    		//**Proprietes du moteur**//
    		RecognizerProperties prop = rec.getRecognizerProperties();
    		System.out.println("Niveau de confiance: "+prop.getConfidenceLevel());
    		System.out.println("Sensibilite: "+prop.getSensitivity());
    		System.out.println("Rapport vitesse/precision "+prop.getSpeedVsAccuracy());
    		System.out.println("Rapport vitesse/precision "+prop.getSpeedVsAccuracy());
    		//**Proprietes du moteur**//
     
    		//**Chargement de regles de grammaire et activation**//
    		//URL base = new URL("http://127.0.0.1/java/grammaire/");
    		//String nom = "gramm";
    		//gram = rec.loadJSGF(base, nom);
    		//gram.setEnabled(true);
    		//**Chargement de regles de grammaire et activation**//	
     
    		//**Association de la grammaire au moteur**//
    		//rec.commitChanges();
    		//**Association de la grammaire au moteur**//
     
    		//**Grammaire active?**//	
    		//System.out.println("Grammaire active? "+gram.isActive());
    		//**Grammaire active?**//
     
    		//**Ajout d'un ecouteur**//
    		rec.addResultListener(this);
    		rec.addEngineListener(this);
    		//**Ajout d'un ecouteur**//
     
    		//**Affichage du type de grammaire dont dispose le moteur par defaut**//
    		System.out.println("Regles de grammaire? "+rec.getRuleGrammar(null));
    		System.out.println("Dictee? "+rec.getDictationGrammar(null));
    		//**Affichage du type de grammaire dont dispose le moteur par defaut**//
     
    		//**Demande du focus et debut de l'ecoute**//
    		new Thread(new Runnable() {
    			public void run(){
    				try{
    				rec.requestFocus();
    				rec.resume();
    				}
    				catch(Exception e){
     
    				}
    			}
    		}).start();
    		//**Demande du focus et debut de l'ecoute**//
     
    		//**Attente de validation**//
    		rec.waitEngineState(rec.FOCUS_ON);
    		rec.waitEngineState(rec.RESUMED);
    		//**Attente de validation**//
     
    		System.out.println("Ecoute...");	
    	}
    	public void resultRejected(ResultEvent e){
    		System.out.println("noooooooooooo");
    	}
    	public void resultAccepted(ResultEvent e) {
    		Result r = (Result)(e.getSource());
    		ResultToken tokens[] = r.getBestTokens();
     
    		//**Affichage du texte détecté dans la console et dans le paneau de dessin**//
    		for (int i = 0; i < tokens.length; i++){
    			System.out.print(tokens[i].getSpokenText() + " ");
    			fen.setT((String) tokens[i].getSpokenText()+ " ");
    		//**Affichage du texte détecté dans la console et dans le paneau de dessin**//
     
    			//**Commandes vocales**//
    			ResultToken token = r.getBestToken(0);
     
    			//**Affichage vocal module saisie**//
    			if((token.getSpokenText().equalsIgnoreCase("Saisis")) | (token.getSpokenText().equalsIgnoreCase("Saisie"))| (token.getSpokenText().equalsIgnoreCase("Saisir"))| (token.getSpokenText().equalsIgnoreCase("Saisie"))| (token.getSpokenText().equalsIgnoreCase("Saisies"))| (token.getSpokenText().equalsIgnoreCase("Saisi")))
    				this.afficheDictee();
    			//**Affichage vocal module saisie**//
     
    			//**Affichage vocal module dessin**//
    			if(token.getSpokenText().equalsIgnoreCase("Dessinée") | (token.getSpokenText().equalsIgnoreCase("Dessinées"))| (token.getSpokenText().equalsIgnoreCase("Dessiner"))| (token.getSpokenText().equalsIgnoreCase("Dessiné")))
    				this.afficheDessin();
    			//**Affichage vocal module dessin**//
     
    			//**Affichage vocal module web**//
    			if(token.getSpokenText().equalsIgnoreCase("Navigateur") | (token.getSpokenText().equalsIgnoreCase("Navigateurs")))
    				this.afficheWeb();
    			//**Affichage vocal module web**//
     
    			//**Ouverture yahoo.fr**//
    			if((fen.l1.isVisible()) & (token.getSpokenText().equalsIgnoreCase("Zéro") | token.getSpokenText().equalsIgnoreCase("0"))){
    				bc.displayURL("http://www.yahoo.fr");
    			}
    			//**Ouverture yahoo.fr**//
     
    			//**Ouverture google.fr**//
    			if((fen.l1.isVisible()) & (token.getSpokenText().equalsIgnoreCase("Cinq") | token.getSpokenText().equalsIgnoreCase("5"))){
    				bc.displayURL("http://www.yahoo.fr");
    			}
    			//**Ouverture google.fr**//
     
    			//**Ouverture ensit.ci**//
    			if((fen.l1.isVisible()) & (token.getSpokenText().equalsIgnoreCase("Dix") | token.getSpokenText().equalsIgnoreCase("10"))){
    				bc.displayURL("http://www.ensit.ci");
    			}
    			//**Ouverture ensit.ci**//
     
    			//**Deplacements module de dessin**//
    			//**Deplacement droit**//
    			if(tokens[i].getSpokenText().equalsIgnoreCase("Droit") | tokens[i].getSpokenText().equalsIgnoreCase("Droite")){
    				fen.pandessin.setDroite();
    			}
    			//**Deplacement droit**//
     
    			//**Deplacement gauche**//
    			if(tokens[i].getSpokenText().equalsIgnoreCase("Gauche")){
    				fen.pandessin.setGauche();
    			}
    			//**Deplacement gauche**//
     
    			//**Deplacement haut**//
    			if(tokens[i].getSpokenText().equalsIgnoreCase("au") | tokens[i].getSpokenText().equalsIgnoreCase("haut")){
    				fen.pandessin.setHaut();
    			}
    			//**Deplacement haut**//
     
    			//**Deplacement bas**//
    			if(tokens[i].getSpokenText().equalsIgnoreCase("Bas")){
    				fen.pandessin.setBas();
    			}
    			//**Deplacement bas**//
    			//**Deplacements module de dessin**//
    			//**Commandes vocales**//
     
    		}
     
    		try {
    			rec.waitEngineState(rec.LISTENING);
    		} catch (IllegalArgumentException e2) {
    			// TODO Auto-generated catch block
    			e2.printStackTrace();
    		} catch (InterruptedException e2) {
    			// TODO Auto-generated catch block
    			e2.printStackTrace();
    		}
    		// Deallocate the recognizer and exit
    		//try {
    		//	rec.deallocate();
    		//} catch (EngineException e1) {
    			// TODO Auto-generated catch block
    		//	e1.printStackTrace();
    		//} catch (EngineStateError e1) {
    			// TODO Auto-generated catch block
    		//	e1.printStackTrace();
    		//}System.out.println("out");
    		//System.exit(0);
    		//**Deallocate the recognizer and exit**//
     
    		//**Statut du moteur**//
    		//System.out.println("Statut du moteur: "+rec.getEngineState());
    		//**Statut du moteur**//
    	}
     
    	public void changesCommitted(RecognizerEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void focusGained(RecognizerEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void focusLost(RecognizerEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void recognizerListening(RecognizerEvent arg0) {
    		// TODO Auto-generated method stub
    		fen.setE();
    	}
    	@Override
    	public void recognizerProcessing(RecognizerEvent arg0) {
    		// TODO Auto-generated method stub
    		fen.setT();
    	}
    	public void actionPerformed(ActionEvent ev) {
     
    		//**Affichage zone de saisie**//
    		if((String) fen.combo.getSelectedItem() == "Saisie"){
    			this.afficheDictee();
    		}
    		//**Affichage zone de saisie**//
     
    		//**Affichage zone de dessin**//
    		if((String) fen.combo.getSelectedItem() == "Dessiner"){
    			this.afficheDessin();
    		}
    		//**Affichage zone de dessin**//
     
    		//**Affichage zone web**//
    		if((String) fen.combo.getSelectedItem() == "Navigateur"){
    			this.afficheWeb();
    		}
    		//**Affichage zone web**//
     
    	}
    	@Override
    	public void recognizerSuspended(RecognizerEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void engineAllocated(EngineEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void engineAllocatingResources(EngineEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void engineDeallocated(EngineEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void engineDeallocatingResources(EngineEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void engineError(EngineErrorEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void enginePaused(EngineEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void engineResumed(EngineEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
     
    	//**Affichage zone de saisie**//
    	public void afficheDictee(){
    		fen.ztexte.setVisible(true);
    		fen.pandessin.setVisible(false);
    		fen.enregistrer.setVisible(true);
    		fen.l1.setVisible(false);
    		fen.l2.setVisible(false);
    		fen.l3.setVisible(false);
    	}
    	//**Affichage zone de saisie**//
     
    	//**Affichage zone de dessin**//
    	public void afficheDessin(){
    		fen.ztexte.setVisible(false);
    		fen.pandessin.setVisible(true);
    		fen.enregistrer.setVisible(false);
    		fen.l1.setVisible(false);
    		fen.l2.setVisible(false);
    		fen.l3.setVisible(false);
    	}
    	//**Affichage zone de dessin**//
     
    	//**Affichage zone web**//
    	public void afficheWeb(){
    		fen.ztexte.setVisible(false);
    		fen.pandessin.setVisible(false);
    		fen.enregistrer.setVisible(false);
    		fen.l1.setVisible(true);
    		fen.l2.setVisible(true);
    		fen.l3.setVisible(true);
    	}
    	//**Affichage zone web**//
     
     
    	private Recognizer rec; 
    	private Grammar gram;
    	private Fenetre fen;
    	private BrowserControl bc;
    }
     
    class Fenetre extends JFrame implements MouseListener{
    	public Fenetre(){
    		setTitle("MEPHYSTO");
    		setBounds(350, 200, 600, 500);
    		Container c = getContentPane();
    		this.setLayout(null);
     
    		//**Logo**//
    		logo = new Logo();
    		logo.setBounds(2, 2, 102, 80);
    		c.add(logo);
    		//**Logo**//
     
    		//**Zone de texte**//
    		ztexte = new TextArea(" ", 3, 15, 1);
    		ztexte.setBounds(50, 95, 500, 150);
    		c.add(ztexte);
    		//**Zone de texte**//
     
    		//**Zone de dessin**//
    		pandessin = new PanDessin();
    		pandessin.setBackground(Color.lightGray);
    		pandessin.setBounds(50, 95, 500, 150);
    		pandessin.setVisible(false);
    		c.add(pandessin);
    		//**Zone de dessin**//
     
    		//**Zone web**//
    		l1 = new JLabel("0-www.yahoo.fr");
    		l1.setVisible(false);
    		l1.setBounds(60, 105, 120, 30);
    		c.add(l1);
    		l2 = new JLabel("5-www.google.fr");
    		l2.setVisible(false);
    		l2.setBounds(60, 150, 120, 30);
    		c.add(l2);
    		l3 = new JLabel("10-www.ensit.ci");
    		l3.setVisible(false);
    		l3.setBounds(60, 195, 120, 30);
    		c.add(l3);
    		//**Zone web**//
     
    		//**Modules**//
    		mod = new JLabel("Modules:");
    		mod.setBounds(205, 400, 90, 30);
    		c.add(mod);
    		combo = new JComboBox(modules);
    		combo.setBounds(305, 400, 90, 30);
    		c.add(combo);
    		//**Modules**//
     
    		//**Boutons de commande**//
    		ecoute = new JButton("Ecoute");
    		ecoute.setBounds(50, 290, 90, 30);
    		c.add(ecoute);
    		pause = new JButton("Pause");
    		pause.setBounds(150, 290, 90, 30);
    		c.add(pause);
    		enregistrer  = new JButton("Enregistrer");
    		enregistrer.setBounds(445, 290, 100, 30);
    		c.add(enregistrer);
    		//**Boutons de commande**//
     
    		//**Statut**//
    		tstatut = new JLabel("Statut : ===>");
    		tstatut.setBounds(400, 40, 90, 30);
    		c.add(tstatut);
    		statut = new JLabel("Ecoute...");
    		statut.setBounds(500, 40, 100, 30);
    		c.add(statut);
    		//**Statut**//
     
    		//**Ecouteur presse-papier**//
    		enregistrer.addMouseListener(this);
    		//**Ecouteur presse-papier**//
    	}
     
    	//**Statut ecoute**//
    	public void setE(){
    		statut.setText("Ecoute...");
    	}
    	//**Statut ecoute**//
     
    	//**Statut traitement**//
    	public void setT(){
    		statut.setText("Traitement...");
    	}
    	//**Statut traitement**//
     
    	//**Ajout du texte**//
    	public void setT(String t){
    		//ztexte.setText(t);
    		ztexte.append(t);
    	}
    	//**Ajout du texte**//
     
     
    	//**Copie du texte dans le presse-papier**//
    	public void mouseClicked(MouseEvent ev) {
    		String texte = ztexte.getText();
    		Toolkit toolKit = Toolkit.getDefaultToolkit();
    		Clipboard cb = toolKit.getSystemClipboard();
    		cb.setContents(new StringSelection(texte), null);
    		JOptionPane.showMessageDialog(null, "Zone de texte copiée dans le presse-papier");
    	}
    	//**Copie du texte dans le presse-papier**//
     
    	@Override
    	public void mouseEntered(MouseEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void mouseExited(MouseEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void mousePressed(MouseEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void mouseReleased(MouseEvent arg0) {
    		// TODO Auto-generated method stub
     
    	}
    	private JButton b;
    	private Logo logo;
    	public JLabel l1, l2, l3, mod;
    	public TextArea ztexte;
    	public JButton ecoute, pause, enregistrer;
    	public PanDessin pandessin;
    	private JLabel tstatut, statut; 
    	public JComboBox combo;
    	private String []modules = {"Saisie", "Dessiner", "Navigateur"};
    }
     
    //**Affichage du logo**//
    class Logo extends JPanel{
    	public Logo(){
    		setSize(102, 80);
    	}
    	public void paint(Graphics g_arg){	
    		try {
    			BufferedImage image = ImageIO.read(new File("c:/Mephysto.png"));
    			g_arg.drawImage(image,0,0,this);
     
    		} catch
    		(IOException e){/*...*/}		
    	}
    }
    //**Affichage du logo**//
     
    //**Paneau de dessin**//
    class PanDessin extends JPanel{
    	public void paintComponent(Graphics g){
    		super.paintComponent(g);
    		g.drawRect(x, y, 25, 25);
    	}
    	public void setDroite(){
    		x += 15;
    		this.repaint();
    	}
    	public void setGauche(){
    		x -= 15;
    		this.repaint();
    	}
    	public void setHaut(){
    		y -= 15;
    		this.repaint();
    	}
    	public void setBas(){
    		y += 15;
    		this.repaint();
    	}
    	private int x = 220, y = 60;
    }
    //**Paneau de dessin**//
     
    //**Navigateur**//
    class BrowserControl {
     
    	static boolean displayURL(String url) {
     
    	 boolean result = true;
    	 String cmd = null;
     
    	 try {
    	  cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    	  Process p = Runtime.getRuntime().exec(cmd);
    	 }
    	 catch(IOException ex) {
    	  // couldn't exec browser
    	  result = false;
    	  System.err.println("Could not invoke browser, command=" +cmd);
    	  System.err.println("Caught: " + ex);
    	 }
    	 return result;
    	}
     
    	private static final String WIN_PATH = "rundll32";
    	private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
    	}
    //**Navigateur**//
    On m'a donné un exemple d’exécution pour un fichier son existant et pas pour un fichier audio passé via un micro par exemple ( c'est ce que je veux moi). pouvez vous m'indiquer ce que je dois mettre dans ce 2em programme comme "fichier son via microphone" pour pouvoir l’exécuter sur le serveur.

    Voici une partie du code qui m'ont fourni
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
     
    public InputStreamEntity setAudioContent() throws NumberFormatException, Exception // add public
    	{
    		File f = new File(audioFile);
    		if( !f.exists() )
    		{
     
    			System.out.println("Audio file does not exist: " + audioFile);
    			return null;
    		}
    		if( !isStreamed )
    		{
    			fileSize = f.length();
    		}
     
    		FileAudioStreamer fs = new FileAudioStreamer(audioFile, isStreamed , encodeToSpeex, Integer.parseInt(sampleRate));
    		InputStreamEntity reqEntity  = new InputStreamEntity(fs.getInputStream(), -1);
    		fs.start();
     
    		reqEntity.setContentType(CODEC);
     
    		//reqEntity.setChunked(true);
     
    		return reqEntity;
    }
     
     
     
     
    	public String processResponse(HttpResponse response) throws IllegalStateException, IOException  // ajout de public
    	{
    		HttpEntity resEntity = response.getEntity();
    		String recognized = null;
     
    		System.out.println(response.getStatusLine());
    		if (resEntity != null) {
    			System.out.println("Response content length: " + resEntity.getContentLength());
    			System.out.println("Chunked?: " + resEntity.isChunked());
    			System.out.println("Nuance Session Id: " + response.getFirstHeader("x-nuance-sessionid").getValue());
     
    			if(cookie == null){
    				Header cookieHeader = response.getFirstHeader("Set-Cookie");
    				cookie = cookieHeader.getValue();
    				StringTokenizer st = new StringTokenizer(cookie,";");
    				cookie = st.nextToken().trim();
    				System.out.println("Cookie: " + cookie);
    			} 
    			System.out.println("------------------Result----------------------");
     
    			BufferedReader reader = new BufferedReader(
    					new InputStreamReader(resEntity.getContent()));
    			try {
     
    				String sentence;
    				int index = 1;
    				while((sentence = reader.readLine()) != null){
    					// do something useful with the response
    					System.out.println("sentence #" + index++ + " : " + sentence);
    				}
    				recognized = sentence;
    			} catch (IOException ex) {
     
    				// In case of an IOException the connection will be released
    				// back to the connection manager automatically
    				throw ex;
     
    			} catch (RuntimeException ex) {
     
    				// In case of an unexpected exception you may want to abort
    				// the HTTP request in order to shut down the underlying 
    				// connection and release it back to the connection manager.
    				//httppost.abort();
    				throw ex;
     
    			} finally {
     
    				// Closing the input stream will trigger connection release
    				reader.close();
     
    			}
    			resEntity.consumeContent();
    		}
    		return recognized;
    	}
     
    	/**
             * @param args
             * @throws Exception 
             */
    	public static void main(String[] args) throws Exception{
     
    		DictationHTTPClient dictationHttpClient = new DictationHTTPClient();
    		if( !dictationHttpClient.checkArgs(args) )
    			return;
     
    		try {	
    			HttpClient httpclient = dictationHttpClient.getHttpClient();
     
    			InputStreamEntity reqEntity = dictationHttpClient.setAudioContent();
     
    			URI uri = dictationHttpClient.getURI();
    			HttpPost httppost = dictationHttpClient.getHeader(uri, 0);	//fileSize);
    			httppost.setEntity(reqEntity);			
     
    			// Add a debug statement here showing all values being used for this request
    			System.out.println();
    			dictationHttpClient.printSettings();
    			System.out.println();
     
    			System.out.println("----------------- Send Audio ----------------------");
    			System.out.println("executing request " + httppost.getRequestLine());
     
    			HttpResponse response = httpclient.execute(httppost);
     
    			System.out.println();
    			System.out.println("----------------- Processing Response ----------------------");
    			dictationHttpClient.processResponse(response);
     
     
    		} catch(Exception e) {
    			//System.out.println(e.toString());
    			e.printStackTrace(System.out);
    		} finally {
    			// When HttpClient instance is no longer needed, 
    			// shut down the connection manager to ensure
    			// immediate deallocation of all system resources
    			if( dictationHttpClient != null && dictationHttpClient.httpclient != null )
    				dictationHttpClient.httpclient.getConnectionManager().shutdown();
    		}
     
    	}

  2. #2
    Membre du Club
    Homme Profil pro
    Architecte réseau
    Inscrit en
    Juillet 2011
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Architecte réseau
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2011
    Messages : 43
    Points : 43
    Points
    43
    Par défaut
    Voici le site des développeurs de l'entreprise en question http://dragonmobile.nuancemobiledeve...blic/index.php

  3. #3
    Membre du Club
    Homme Profil pro
    Architecte réseau
    Inscrit en
    Juillet 2011
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Architecte réseau
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2011
    Messages : 43
    Points : 43
    Points
    43
    Par défaut
    Voici le site des développeurs de l'entreprise en question http://dragonmobile.nuancemobiledeve...blic/index.php

Discussions similaires

  1. Reconnaissance vocale Java
    Par dharkan dans le forum Débuter avec Java
    Réponses: 2
    Dernier message: 17/07/2012, 07h19
  2. Reconnaissance vocale et filtrage son sous Java
    Par Projet_Java dans le forum Général Java
    Réponses: 0
    Dernier message: 13/09/2011, 10h47
  3. Reconnaissance vocale java
    Par Nicotendo dans le forum Multimédia
    Réponses: 10
    Dernier message: 11/08/2009, 08h27
  4. [Audio] reconnaissance vocale Java
    Par mimaaaa dans le forum Multimédia
    Réponses: 0
    Dernier message: 05/08/2008, 19h03
  5. reconnaissance vocale dans java
    Par adel.87 dans le forum Multimédia
    Réponses: 1
    Dernier message: 07/01/2008, 05h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo