2016-06-20 16 views
-1

Ich arbeite an Sphinx 4, TranscriberDemo.java Programm. Ich habe die Alpha-Version von https://sourceforge.net/projects/cmusphinx/files/sphinx4/5prealpha/ und die folgenden JAR-Dateien heruntergeladenWas wird die Ausgabe von TranscriberDemo.java in Sphinx 4 sein?

sphinx4-data-5prealpha-20160531.163451-9.jar

sphinx4-Core-5prealpha-20160531.163425-9.jar

Aus der Link: https://oss.sonatype.org/#nexus-search;quick~sphinx4

mein Code:

package transcriber; 
import java.io.InputStream; 
import edu.cmu.sphinx.api.Configuration; 
import edu.cmu.sphinx.api.SpeechResult; 
import edu.cmu.sphinx.api.StreamSpeechRecognizer; 
import edu.cmu.sphinx.decoder.adaptation.Stats; 
import edu.cmu.sphinx.decoder.adaptation.Transform; 
import edu.cmu.sphinx.result.WordResult; 

/** 
* A simple example that shows how to transcribe a continuous audio file that 
* has multiple utterances in it. 
*/ 
public class TranscriberDemo { 

public static void main(String[] args) throws Exception { 
    System.out.println("Loading models..."); 

    Configuration configuration = new Configuration(); 

    // Load model from the jar 
    configuration 
      .setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us"); 

    // You can also load model from folder 
    // configuration.setAcousticModelPath("file:en-us"); 

    configuration 
      .setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict"); 
    configuration 
      .setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin"); 

    StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(
      configuration); 
    InputStream stream = TranscriberDemo.class 
      .getResourceAsStream("/edu/cmu/sphinx/demo/aligner/10001-90210-01803.wav"); 
    stream.skip(44); 

    // Simple recognition with generic model 
    recognizer.startRecognition(stream); 
    SpeechResult result; 
    while ((result = recognizer.getResult()) != null) { 

     System.out.format("Hypothesis: %s\n", result.getHypothesis()); 

     System.out.println("List of recognized words and their times:"); 
     for (WordResult r : result.getWords()) { 
      System.out.println(r); 
     } 

     System.out.println("Best 3 hypothesis:"); 
     for (String s : result.getNbest(3)) 
      System.out.println(s); 

    } 
    recognizer.stopRecognition(); 

    // Live adaptation to speaker with speaker profiles 

    stream = TranscriberDemo.class 
      .getResourceAsStream("/edu/cmu/sphinx/demo/aligner/10001-90210-01803.wav"); 
    stream.skip(44); 

    // Stats class is used to collect speaker-specific data 
    Stats stats = recognizer.createStats(1); 
    recognizer.startRecognition(stream); 
    while ((result = recognizer.getResult()) != null) { 
     stats.collect(result); 
    } 
    recognizer.stopRecognition(); 

    // Transform represents the speech profile 
    Transform transform = stats.createTransform(); 
    recognizer.setTransform(transform); 

    // Decode again with updated transform 
    stream = TranscriberDemo.class 
      .getResourceAsStream("/edu/cmu/sphinx/demo/aligner/10001-90210-01803.wav"); 
    stream.skip(44); 
    recognizer.startRecognition(stream); 
    while ((result = recognizer.getResult()) != null) { 
     System.out.format("Hypothesis: %s\n", result.getHypothesis()); 
    } 
    recognizer.stopRecognition(); 

} 
} 

und der Ausgang ist:

Loading models... 
13:36:22.338 INFO unitManager   CI Unit: *+NSN+ 
13:36:22.338 INFO unitManager   CI Unit: *+SPN+ 
13:36:22.348 INFO unitManager   CI Unit: AA 
13:36:22.348 INFO unitManager   CI Unit: AE 
13:36:22.348 INFO unitManager   CI Unit: AH 
13:36:22.348 INFO unitManager   CI Unit: AO 
13:36:22.348 INFO unitManager   CI Unit: AW 
13:36:22.348 INFO unitManager   CI Unit: AY 
13:36:22.348 INFO unitManager   CI Unit: B 
13:36:22.348 INFO unitManager   CI Unit: CH 
13:36:22.348 INFO unitManager   CI Unit: D 
13:36:22.348 INFO unitManager   CI Unit: DH 
13:36:22.348 INFO unitManager   CI Unit: EH 
13:36:22.348 INFO unitManager   CI Unit: ER 
13:36:22.348 INFO unitManager   CI Unit: EY 
13:36:22.348 INFO unitManager   CI Unit: F 
13:36:22.348 INFO unitManager   CI Unit: G 
13:36:22.348 INFO unitManager   CI Unit: HH 
13:36:22.348 INFO unitManager   CI Unit: IH 
13:36:22.348 INFO unitManager   CI Unit: IY 
13:36:22.348 INFO unitManager   CI Unit: JH 
13:36:22.348 INFO unitManager   CI Unit: K 
13:36:22.358 INFO unitManager   CI Unit: L 
13:36:22.358 INFO unitManager   CI Unit: M 
13:36:22.358 INFO unitManager   CI Unit: N 
13:36:22.358 INFO unitManager   CI Unit: NG 
13:36:22.358 INFO unitManager   CI Unit: OW 
13:36:22.358 INFO unitManager   CI Unit: OY 
13:36:22.358 INFO unitManager   CI Unit: P 
13:36:22.358 INFO unitManager   CI Unit: R 
13:36:22.358 INFO unitManager   CI Unit: S 
13:36:22.358 INFO unitManager   CI Unit: SH 
13:36:22.358 INFO unitManager   CI Unit: T 
13:36:22.358 INFO unitManager   CI Unit: TH 
13:36:22.368 INFO unitManager   CI Unit: UH 
13:36:22.368 INFO unitManager   CI Unit: UW 
13:36:22.368 INFO unitManager   CI Unit: V 
13:36:22.368 INFO unitManager   CI Unit: W 
13:36:22.368 INFO unitManager   CI Unit: Y 
13:36:22.368 INFO unitManager   CI Unit: Z 
13:36:22.368 INFO unitManager   CI Unit: ZH 
13:36:24.507 INFO autoCepstrum   Cepstrum component auto-configured as  follows: autoCepstrum {MelFrequencyFilterBank, Denoise, DiscreteCosineTransform2, Lifter} 
Exception in thread "main" java.lang.NullPointerException 
at transcriber.TranscriberDemo.main(TranscriberDemo.java:50) 
Java Result: 1 
BUILD SUCCESSFUL (total time: 7 seconds) 

ich etwas Hilfe brauchen, um richtig, dieses Programm auszuführen. Vielen Dank im Voraus.

+0

Geben Sie mir eine Rückmeldung – ziLk

Antwort

0

Put 10001-90210-01803.wav Datei innerhalb von edu.cmu.sphinx.demo.transcriber Paket und ändern Sie die alle Streams wie unten:

InputStream stream = TranscriberDemo.class 
       .getResourceAsStream("10001-90210-01803.wav"); 

Sie werden diese Befehle erhalten

Loading models... 
Hypothesis: one zero zero zero one 
List of recognized words and their times: 
{what, 0.776, [820:1080]} 
{zero, 0.776, [1090:1490]} 
{zero, 0.997, [1500:1910]} 
{zero, 0.998, [1920:2280]} 
{one, 0.998, [2290:2530]} 
Best 3 hypothesis: 
<s> what zero zero zero one </s> 
<s> what's zero zero zero one </s> 
<s> one zero zero zero one </s> 
Hypothesis: nine oh two one oh 
List of recognized words and their times: 
{<sil>, 0.948, [2830:3910]} 
{bad, 0.949, [3920:4140]} 
{oh, 1.000, [4150:4250]} 
{two, 1.000, [4260:4490]} 
{one, 1.000, [4500:4650]} 
{oh, 1.000, [4660:4890]} 
Best 3 hypothesis: 
<s> bad oh two one oh </s> 
<s> nine oh two one oh </s> 
<s> that oh two one oh </s> 
Hypothesis: cyril one eight sir oh three 
List of recognized words and their times: 
{<sil>, 1.000, [5030:6240]} 
{cyril, 0.999, [6250:6680]} 
{one, 0.999, [6690:6860]} 
{eight, 0.998, [6870:7090]} 
{zero, 0.998, [7100:7460]} 
{three, 0.998, [7470:7900]} 
Best 3 hypothesis: 
<s> zero one eight zero three </s> 
<s> cyril one eight sir oh three </s> 
<s> cyril one eight zero three </s> 
* Decode again with updated transform - Hypothesis: one zero zero zero one 
* Decode again with updated transform - Hypothesis: nine oh two one oh 
* Decode again with updated transform - Hypothesis: cyril one eight zero three