Recent
:: RIFAS
6 hrs ago
:: RIFAS
7 hrs ago
:: This post is secret nox
7 hrs ago
:: This post is secret nox
7 hrs ago
:: This post is secret nox
7 hrs ago
:: This post is secret nox
12 hrs ago
:: RIFAS
13 hrs ago
:: RIFAS
14 hrs ago
:: zacharyj
14 hrs ago
:: zacharyj
14 hrs ago
:: zacharyj
14 hrs ago
:: zacharyj
14 hrs ago
:: zacharyj
14 hrs ago
:: zacharyj
14 hrs ago
:: RIFAS
17 hrs ago
rss 2.0 feed

Make New Post
Posts: 19059

Syntax:       Wrapping:  

   #15184 Posted by janiq 2009-06-21 14:44:17
Formated by GeSHi
  1. import java.io.File;
  2. import java.net.MalformedURLException;
  3. import java.net.URL;
  4.  
  5. import edu.cmu.sphinx.frontend.util.Microphone;
  6. import edu.cmu.sphinx.recognizer.Recognizer;
  7. import edu.cmu.sphinx.result.Result;
  8. import edu.cmu.sphinx.util.props.ConfigurationManager;
  9.  
  10. public class CislaHandler implements RocnikacHandler {
  11. private ConfigurationManager cm;
  12. private Recognizer recognizer;
  13. private Microphone microphone;
  14.  
  15. public String GetRequest() {
  16. Result result = null;
  17. String res = "";
  18. while ((result = recognizer.recognize()) != null) {
  19. if (result != null) {
  20. String resultText = result.getBestResultNoFiller();
  21. res += resultText;
  22. }
  23. }
  24. return res;
  25. }
  26.  
  27. public boolean LoadFirstRequest(String fileName) {
  28. URL url = null;
  29. try {
  30. url = new File(fileName).toURI().toURL();
  31. } catch (MalformedURLException e) {
  32. // TODO Auto-generated catch block
  33. e.printStackTrace();
  34. }
  35.  
  36. cm = new ConfigurationManager(url);
  37.  
  38. // allocate the recognizer
  39. recognizer = (Recognizer) cm.lookup("recognizer");
  40. recognizer.allocate();
  41. System.out.println("Recognizer ok");
  42.  
  43. // start the microphone
  44. microphone = (Microphone) cm.lookup("microphone");
  45. //microphone.startRecording();
  46.  
  47. System.out.println("Microphone ok");
  48. return true;
  49. }
  50.  
  51. public boolean LoadRequest(String fileName) {
  52. recognizer.deallocate();
  53. URL url = null;
  54. try {
  55. url = new File(fileName).toURI().toURL();
  56. } catch (MalformedURLException e) {
  57. // TODO Auto-generated catch block
  58. e.printStackTrace();
  59. }
  60.  
  61. cm = new ConfigurationManager(url);
  62.  
  63. // allocate the recognizer
  64. recognizer = (Recognizer) cm.lookup("recognizer");
  65. recognizer.allocate();
  66. System.out.println("Recognizer ok");
  67.  
  68. // start the microphone
  69. microphone = (Microphone) cm.lookup("microphone");
  70. //microphone.startRecording();
  71.  
  72. System.out.println("Microphone ok");
  73. return true;
  74. }
  75.  
  76. public boolean QuitRequest() {
  77. // TODO Auto-generated method stub
  78. return true;
  79. }
  80.  
  81. public boolean StartRequest() {
  82. microphone.startRecording();
  83. return true;
  84. }
  85.  
  86. public boolean StopRequest() {
  87. microphone.stopRecording();
  88. return true;
  89. }
  90.  
  91. public boolean Initialize() {
  92. /*
  93. URL url;
  94.   url = RocnikacSphinxWrapper.class.getResource("RocnikacSphinxWrapper.config.xml");
  95.  
  96.   cm = new ConfigurationManager(url);
  97.  
  98.   // allocate the recognizer
  99.   recognizer = (Recognizer) cm.lookup("recognizer");
  100.   recognizer.allocate();
  101.   System.out.println("Recognizer ok");
  102.  
  103.   // start the microphone
  104.   microphone = (Microphone) cm.lookup("microphone");
  105.   //microphone.startRecording();
  106.  
  107.   System.out.println("Microphone ok");
  108. // TODO Auto-generated method stub*/
  109. return true;
  110. }
  111.  
  112. }
Parsed in 0.14875102 seconds
::  Inline view Inline view ::  Email this post Email  ::  Print Print   

:: Download   Download Text File15184.txt   Download Gziped text File15184.txt.gz   Download HTML File15184.html   Download PDF File15184.pdf
:: Print into    Print into HTML FileHTML document   Print into PDF FilePDF document

:: Make Diff

:: Erase Post

* Code:

To highlight particular lines, prefix each line with @@


Description:


Secret key (for later deletion)
Syntax:     


comments (0)


Copyright © 2006 Openpastebin