Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:57:48+00:00 2026-06-14T05:57:48+00:00

When I try to run pythontranscriber.py, it fails with the following error: Traceback (most

  • 0

When I try to run pythontranscriber.py, it fails with the following error:

Traceback (most recent call last):
  File "PythonTranscriber.py", line 14, in <module>
  from edu.cmu.sphinx.decoder import Decoder
  ImportError: No module named edu

My script PythonTranscriber.py:

import sys

libDir = "/home/karen/sphinx4-1.0beta5-scr/sphinx4-1.0beta5/src/sphinx4/" 
classPaths = [
    "sphinx4.jar",
    "jsapi.jar" ] 
for classPath in classPaths:
    sys.path.append(libDir + classPath)

true = 1 
false = 0

from edu.cmu.sphinx.decoder import Decoder 
from edu.cmu.sphinx.decoder import ResultListener 
from edu.cmu.sphinx.decoder.pruner import SimplePruner 
from edu.cmu.sphinx.decoder.scorer import ThreadedAcousticScorer 
from edu.cmu.sphinx.decoder.search import PartitionActiveListFactory 
from edu.cmu.sphinx.decoder.search import SimpleBreadthFirstSearchManager 
from edu.cmu.sphinx.frontend import DataBlocker 
from edu.cmu.sphinx.frontend import FrontEnd 
from edu.cmu.sphinx.frontend.endpoint import NonSpeechDataFilter 
from edu.cmu.sphinx.frontend.endpoint import SpeechClassifier 
from edu.cmu.sphinx.frontend.endpoint import SpeechMarker 
from edu.cmu.sphinx.frontend.feature import DeltasFeatureExtractor 
from edu.cmu.sphinx.frontend.feature import LiveCMN 
from edu.cmu.sphinx.frontend.filter import Preemphasizer 
from edu.cmu.sphinx.frontend.frequencywarp import MelFrequencyFilterBank 
from edu.cmu.sphinx.frontend.transform import DiscreteCosineTransform 
from edu.cmu.sphinx.frontend.transform import DiscreteFourierTransform 
from edu.cmu.sphinx.frontend.util import AudioFileDataSource 
from edu.cmu.sphinx.frontend.window import RaisedCosineWindower 
from edu.cmu.sphinx.instrumentation import BestPathAccuracyTracker 
from edu.cmu.sphinx.instrumentation import MemoryTracker 
from edu.cmu.sphinx.instrumentation import SpeedTracker 
from edu.cmu.sphinx.jsapi import JSGFGrammar 
from edu.cmu.sphinx.linguist.acoustic import UnitManager 
from edu.cmu.sphinx.linguist.acoustic.tiedstate import Sphinx3Loader 
from edu.cmu.sphinx.linguist.acoustic.tiedstate import TiedStateAcousticModel 
from edu.cmu.sphinx.linguist.dictionary import FastDictionary 
from edu.cmu.sphinx.linguist.flat import FlatLinguist 
from edu.cmu.sphinx.recognizer import Recognizer 
from edu.cmu.sphinx.util import LogMath 
from java.util.logging import Logger 
from java.util.logging import Level 
from java.net import URL 
from java.util import ArrayList

# if (args.length < 1) {
#  throw new Error("USAGE: GroovyTranscriber <sphinx4 root> [<WAV file>]")
# }

root = "../../.."

# init common  
Logger.getLogger("").setLevel(Level.WARNING) 
logMath = LogMath(1.0001, true) 
absoluteBeamWidth = -1 
relativeBeamWidth = 1E-80 
wordInsertionProbability = 1E-36 
languageWeight = 8.0

# init audio data 
audioSource = AudioFileDataSource(3200, None) 
audioURL =  URL("file:" + root + "/src/apps/edu/cmu/sphinx/demo/transcriber/10001-90210-01803.wav")

# (args.length > 1) ?
#  File(args[0]).toURI().toURL() :   audioSource.setAudioFile(audioURL, None)

# init front end 
dataBlocker = DataBlocker(
        10 # blockSizeMs ) speechClassifier = SpeechClassifier(
        10,     # frameLengthMs,
        0.003, # adjustment,
        10,     # threshold,
        0       # minSignal 
)

speechMarker = SpeechMarker(
        200, # startSpeechTime,
        500, # endSilenceTime,
        100, # speechLeader,
        50,  # speechLeaderFrames
        100  # speechTrailer 
)

nonSpeechDataFilter = NonSpeechDataFilter()

premphasizer = Preemphasizer(
        0.97 # preemphasisFactor 
) 
windower = RaisedCosineWindower(
        0.46, # double alpha
        25.625, # windowSizeInMs
        10.0 # windowShiftInMs 
) 
fft = DiscreteFourierTransform(
        -1, # numberFftPoints
        false # invert 
) 
melFilterBank = MelFrequencyFilterBank(
        130.0, # minFreq,
        6800.0, # maxFreq,
        40 # numberFilters 
) 
dct = DiscreteCosineTransform(
        40, # numberMelFilters,
        13  # cepstrumSize 
) 
cmn = LiveCMN(
        12.0, # initialMean,
        100,  # cmnWindow,
        160   # cmnShiftWindow 
) 
featureExtraction = DeltasFeatureExtractor(
        3 # window 
)

pipeline = [
        audioSource,
        dataBlocker,
        speechClassifier,
        speechMarker,
        nonSpeechDataFilter,
        premphasizer,
        windower,
        fft,
        melFilterBank,
        dct,
        cmn,
        featureExtraction ]

frontend = FrontEnd(pipeline)

# init models 
unitManager = UnitManager()

modelLoader = Sphinx3Loader(
        "file:" + root + "/models/acoustic/tidigits/model.props",
        logMath,
        unitManager,
        true,
        true,
        39,
        "file:" + root + "/models/acoustic/tidigits/wd_dependent_phone.500.mdef",
        "file:" + root + "/models/acoustic/tidigits/wd_dependent_phone.cd_continuous_8gau/",
        0.0,
        1e-7,
        0.0001,
        true)

model = TiedStateAcousticModel(modelLoader, unitManager, true)

dictionary = FastDictionary(
        URL("file:" + root + "/models/acoustic/tidigits/dictionary"),
        URL("file:" + root + "/models/acoustic/tidigits/fillerdict"),
        ArrayList(),
        false,
        "<sil>",
        false,
        false,
        unitManager)

# init linguist 
grammar = JSGFGrammar(
        # URL baseURL,
        URL("file:" + root + "/src/apps/edu/cmu/sphinx/demo/transcriber/"),
        logMath, # LogMath logMath,
        "digits", # String grammarName,
        false, # boolean showGrammar,
        false, # boolean optimizeGrammar,
        false, # boolean addSilenceWords,
        false, # boolean addFillerWords,
        dictionary # Dictionary dictionary 
)

linguist = FlatLinguist(
        model, # AcousticModel acousticModel,
        logMath, # LogMath logMath,
        grammar, # Grammar grammar,
        unitManager, # UnitManager unitManager,
        wordInsertionProbability, # double wordInsertionProbability,
        1.0, # double silenceInsertionProbability,
        1.0, # double fillerInsertionProbability,
        1.0, # double unitInsertionProbability,
        languageWeight, # float languageWeight,
        false, # boolean dumpGStates,
        false, # boolean showCompilationProgress,
        false, # boolean spreadWordProbabilitiesAcrossPronunciations,
        false, # boolean addOutOfGrammarBranch,
        1.0, # double outOfGrammarBranchProbability,
        1.0, # double phoneInsertionProbability,
        None # AcousticModel phoneLoopAcousticModel 
)

# init recognizer 
scorer = ThreadedAcousticScorer(frontend, None, 10, true, 0)

pruner = SimplePruner()

activeListFactory = PartitionActiveListFactory(absoluteBeamWidth, relativeBeamWidth, logMath)

searchManager = SimpleBreadthFirstSearchManager(
        logMath, linguist, pruner,
        scorer, activeListFactory,
        false, 0.0, 0, false)

decoder = Decoder(searchManager,
        false, false,
        ArrayList(),
        100000)

recognizer = Recognizer(decoder, None)

# allocate the resourcs necessary for the recognizer recognizer.allocate()

# Loop unitl last utterance in the audio file has been decoded, in which case the recognizer will return None. 
result = recognizer.recognize() 
while (result != None):
    resultText = result.getBestResultNoFiller()
    print resultText
    result = recognizer.recognize()

I have Jython installed already!

Please help me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:57:50+00:00Added an answer on June 14, 2026 at 5:57 am

    To load Java code, try adding jars to your classpath.

    If you’re not familiar with how to do that, either use

     export CLASSPATH=$CLASSPATH:/path/to/sphinx4.jar:/path/jsapi.jar
    

    Or add it to your command line script:

    java -cp /path/to/jars -jar /home/karen/jython-installer-2.5.3/jython.jar PythonTranscriber.py
    

    EDIT:

    1. So, I followed the instructions here to download and install Sphinx-4. The path to the jar files was different than you had in your script. They were under the sphinx4/lib directory. You may want to double-check the correctness of your path.

    2. I ran your script as below (modified, but no major changes):

      import sys,os
      lib_dir = '/home/.../jars/sphinx4/lib/'
      classpaths = [ 'sphinx4.jar', 'jsapi.jar' ]
      for cp in classpaths:
          sys.path.append(os.path.join(lib_dir,cp))
      
      from edu.cmu.sphinx.decoder import Decoder
      from ... import ...
      etc.
      from java.util import ArrayList
      

      with the command:

      jython python_transcriber.py
      
    3. This almost worked, except that you have one more import error:

      from edu.cmu.sphinx.jsapi import JSGFGrammar
      

      should, according to the javadoc, be:

      from edu.cmu.sphinx.jsgf import JSGFGrammar
      

    That took care of it for me. Didn’t try the rest of the code, but at least all the imports work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just installed play-2.0 and keep getting the following error when I try run
I'm getting error when try run my recept: and run following commands: $> rails
I'm getting this error when I try run DB:Rake : ** Invoke db:migrate (first_time)
I try to run the following raw query in android, it seems not work
I try to run jsf application in myeclipse using jboss web server and following
I try to run the following code: public void Init(Url rootUrl) { var web
I try to run the following script in R (minimized example): library(neuralnet) arrhythmia <-
When I try run make from cmd-console on Windows, it runs Turbo Delphi's make.exe
When I run the code below I get the following error. C:\Documents and Settings\BOS\Desktop\test>java
When I try to run a .NET assembly ( boo.exe ) from a network

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.