cmusphinx / sphinx4

Pure Java speech recognition library
cmusphinx.sourceforge.net
Other
1.4k stars 587 forks source link

AlignerDemo does not run #41

Closed nicoayroles closed 8 years ago

nicoayroles commented 8 years ago

Hi all, I am trying to use CMU Sphinx for the first time to do speech-text alignment. I have created a Java project and imported sphinx4-core and sphinx4-data jars as libraries.

First, I tried to run the instructions in http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4 but the following line does not compile because there is no SpeechAligner constructor with a single Configuration argument: SpeechAligner aligner = new SpeechAligner(configuration);

Thus, I turned to sphinx4-samples and used to AlignerDemo. My current code is:

import java.io.File; import java.net.URL; import java.util.List;

import edu.cmu.sphinx.api.SpeechAligner; import edu.cmu.sphinx.result.WordResult;

public class TextAlignment {

public static void main(String args[]) throws Exception {

    String acousticModelPath = "resource:/edu/cmu/sphinx/models/en-us/en-us";
    String dictionaryPath = "resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict";
    String g2pPath = "resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin";
    SpeechAligner aligner = new SpeechAligner(acousticModelPath, dictionaryPath, g2pPath);

    URL audioURL = new File("data/10001-90210-01803.wav").toURI().toURL();
    List<WordResult> results = aligner.align(audioURL, "one zero zero zero one nine oh two one oh zero one eight zero three");
}

}

Unfortunately, the last line results in the following error:

16:42:25.049 INFO dictionary Loading dictionary from: jar:file:/home/nicolas/IdeaProjects/TextAlignment/lib/sphinx4-data-1.0-20150630.174256-9.jar!/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict 16:42:25.211 INFO dictionary Loading filler dictionary from: jar:file:/home/nicolas/IdeaProjects/TextAlignment/lib/sphinx4-data-1.0-20150630.174256-9.jar!/edu/cmu/sphinx/models/en-us/en-us/noisedict Exception in thread "main" java.lang.RuntimeException: Allocation of search manager resources failed at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.allocate(WordPruningBreadthFirstSearchManager.java:247) at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:103) at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:164) at edu.cmu.sphinx.api.SpeechAligner.align(SpeechAligner.java:110) at edu.cmu.sphinx.api.SpeechAligner.align(SpeechAligner.java:65) at edu.cmu.sphinx.demo.aligner.TextAlignment.main(TextAlignment.java:35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: java.io.StreamCorruptedException: invalid stream header: 54726965 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804) at java.io.ObjectInputStream.(ObjectInputStream.java:299) at edu.cmu.sphinx.fst.ImmutableFst.loadModel(ImmutableFst.java:169) at edu.cmu.sphinx.linguist.g2p.G2PConverter.(G2PConverter.java:86) at edu.cmu.sphinx.linguist.dictionary.TextDictionary.allocate(TextDictionary.java:189) at edu.cmu.sphinx.linguist.lextree.LexTreeLinguist.allocate(LexTreeLinguist.java:332) at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.allocate(WordPruningBreadthFirstSearchManager.java:243) ... 10 more

Do you have any idea what I am doing wrong?

Thanks a lot, Nicolas

timobaumann commented 8 years ago

Am 03.11.2015 um 16:43 schrieb nicoayroles:

Caused by: java.io.StreamCorruptedException: invalid stream header: 54726965 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804) at java.io.ObjectInputStream.(ObjectInputStream.java:299) at edu.cmu.sphinx.fst.ImmutableFst.loadModel(ImmutableFst.java:169) at edu.cmu.sphinx.linguist.g2p.G2PConverter.(G2PConverter.java:86) you're loading the language model as a G2P model. Double-check with whereever you copy-pasted from. Timo

Timo Baumann, Wissenschaftlicher Mitarbeiter

Fachbereich Informatik, Universität Hamburg AB Natürlichsprachliche Systeme

http://nats-www.informatik.uni-hamburg.de/User/TimoBaumann

nicoayroles commented 8 years ago

You're right, I didn't notice the demo use 'null' for the third argument. And I guess I don't need a language model if I only want to do alignment.

Thanks for your quick response. Much appreciated.

Nicolas