2016-11-12 72 views
1

我所做的這些步驟不知道要開始測試sphinx4

哪些類

1-從網上下載https://sourceforge.net/projects/cmusphinx/files/sphinx4/5prealpha/

2- Sphinx4的最新版本安裝搖籃IDE包3.8.x + 1.0.x的Eclipse中的(Gradle插件)。

3-將Sphinx4導入爲Gradle STS項目。

現在,我得到的錯誤如下圖所示畫面

enter image description here

由於時間的緣故,我已經評論這些錯誤,因爲我不知道爲什麼這些錯誤我正在做的。

現在我想運行Sphinx4,但我不知道要運行什麼以及如何運行。 我已經盡最大努力與谷歌,並試圖做幾天。但沒有得到積極的結果。

如果任何人可以幫助我解決問題,並指導我如何將sphinx4作爲gradle運行,那將非常棒。正如你可以看到有4個項目獅身人面像,以便運行哪一個。

這可能是愚蠢的問,「如果我成功運行會是怎樣輸出」

PS:我是新來的搖籃和Sphinx4 和this link

回答

1

教程says

也採取看看

sphinx4源代碼中包含了許多示例演示,以便您瞭解如何運行Sphinx4。您可以從sphinx4樣本罐子運行它們:

  • Transcriber - 演示瞭如何錄製文件
  • 對話框 - 說話人識別
  • 定位儀 - - 示範演示瞭如何與用戶
  • SpeakerID導致對話框的音頻轉錄時間戳

你只需要仔細閱讀它。

+0

尼古拉,你可以看一下這個問題:HTTP://計算器。 COM /問題/ 40691518 /化妝sphinx4 - 認識 - 所有的號碼s-using-custom-gram-file? :) – GOXR3PLUS

0

發生這些錯誤是因爲您的編碼設置不正確。

在Eclipse中去Edit -> Set Encoding -> UTF-8

+0

完成但仍然存在錯誤。 –

+0

如果一切順利,它應該將這些奇怪的標誌更改爲:https://gyazo.com/5d8494538630eeb60d94646e5acb0506還要確保先打開文件,然後再進行編碼。該設置僅更改打開的文件的編碼!與我的項目USEnglishTokenizer也有這個問題:https://gyazo.com/0f99cab48e7fde07a5b5fc1ea92315c7如果你仍然有一個錯誤,應該有其他的東西是錯誤的 – Hespen

1

你可以找到教程: - >here < -

雖然我加入罐子到類路徑不同它會爲你工作。


簡單的示例代碼:

import java.io.IOException; 
import java.util.logging.Level; 
import java.util.logging.Logger; 

import javax.sound.sampled.AudioSystem; 
import javax.sound.sampled.Port; 

import edu.cmu.sphinx.api.Configuration; 
import edu.cmu.sphinx.api.LiveSpeechRecognizer; 
import edu.cmu.sphinx.api.SpeechResult; 

public class Main { 

    // Logger 
    private Logger logger = Logger.getLogger(getClass().getName()); 

    // Variables 
    private String result; 

    // Threads 
    Thread speechThread; 
    Thread resourcesThread; 

    // LiveRecognizer 
    private LiveSpeechRecognizer recognizer; 

    /** 
    * Constructor 
    */ 
    public Main() { 

     // Loading Message 
     logger.log(Level.INFO, "Loading..\n"); 

     // Configuration 
     Configuration configuration = new Configuration(); 

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

     // if you want to use LanguageModelPath disable the 3 lines after which 
     // are setting a custom grammar-> 

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

     // Grammar 
     configuration.setGrammarPath("resource:/grammars"); 
     configuration.setGrammarName("grammar"); 
     configuration.setUseGrammar(true); 

     try { 
      recognizer = new LiveSpeechRecognizer(configuration); 
     } catch (IOException ex) { 
      logger.log(Level.SEVERE, null, ex); 
     } 

     // Start recognition process pruning previously cached data. 
     recognizer.startRecognition(true); 

     // Start the Thread 
     startSpeechThread(); 
     startResourcesThread(); 
    } 

    /** 
    * Starting the main Thread of speech recognition 
    */ 
    protected void startSpeechThread() { 

     // alive? 
     if (speechThread != null && speechThread.isAlive()) 
      return; 

     // initialise 
     speechThread = new Thread(() -> { 
      logger.log(Level.INFO, "You can start to speak...\n"); 
      try { 
       while (true) { 
        /* 
        * This method will return when the end of speech is 
        * reached. Note that the end pointer will determine the end 
        * of speech. 
        */ 
        SpeechResult speechResult = recognizer.getResult(); 
        if (speechResult != null) { 

         result = speechResult.getHypothesis(); 
         System.out.println("You said: [" + result + "]\n"); 
         // logger.log(Level.INFO, "You said: " + result + "\n") 

        } else 
         logger.log(Level.INFO, "I can't understand what you said.\n"); 

       } 
      } catch (Exception ex) { 
       logger.log(Level.WARNING, null, ex); 
      } 

      logger.log(Level.INFO, "SpeechThread has exited..."); 
     }); 

     // Start 
     speechThread.start(); 

    } 

    /** 
    * Starting a Thread that checks if the resources needed to the 
    * SpeechRecognition library are available 
    */ 
    protected void startResourcesThread() { 

     // alive? 
     if (resourcesThread != null && resourcesThread.isAlive()) 
      return; 

     resourcesThread = new Thread(() -> { 
      try { 

       // Detect if the microphone is available 
       while (true) { 
        if (AudioSystem.isLineSupported(Port.Info.MICROPHONE)) { 
         // logger.log(Level.INFO, "Microphone is available.\n") 
        } else { 
         // logger.log(Level.INFO, "Microphone is not 
         // available.\n") 

        } 

        // Sleep some period 
        Thread.sleep(350); 
       } 

      } catch (InterruptedException ex) { 
       logger.log(Level.WARNING, null, ex); 
       resourcesThread.interrupt(); 
      } 
     }); 

     // Start 
     resourcesThread.start(); 
    } 

    /** 
    * Takes a decision based on the given result 
    */ 
    public void makeDesicion(String result) { 
     //implemented in the part 2 
    } 

    /** 
    * Java Main Application Method 
    * 
    * @param args 
    */ 
    public static void main(String[] args) { 

     // // Be sure that the user can't start this application by not giving 
     // the 
     // // correct entry string 
     // if (args.length == 1 && "SPEECH".equalsIgnoreCase(args[0])) 
     new Main(); 
     // else 
     // Logger.getLogger(Main.class.getName()).log(Level.WARNING, "Give me 
     // the correct entry string.."); 

    } 

} 

語法文件:

#JSGF V1.0; 

/** 
* JSGF Grammar 
*/ 

grammar grammar; 

public <numbers> = (one | two | three| four| five | six | seven | eight | nine | ten); 
public <action> = (plus | minus | multiply | division); 
public <final> = (show result); 
+0

它是幫助完整。我會探索它,並會讓你知道 –

+0

@Adnan Ali這是一個LiveSpeechRecognition的完整實例。它用於實際的應用程序代碼;) – GOXR3PLUS

+0

@AdnanAli你有沒有探索它?告訴我們你什麼時候到達你的應用程序 – Abderrahim