2016-03-22 20 views
1

我一直在試圖包圍我的頭周圍使用sphinx4得到一個靜止圖像動畫時,我的女朋友談twitch.tv。一些非常像這個一般mittenz傢伙https://www.youtube.com/watch?v=L2oUE-C2g6Y說話的貓是我試圖效仿。試圖讓一個靜止的圖像'談''當有人在JAVA談話

當我需要將圖像引入等式時,我迷路了。我一直以此爲例。

`package edu.cmu.sphinx.demo.hellowrld; 
import edu.cmu.sphinx.frontend.util.Microphone; 
import edu.cmu.sphinx.recognizer.Recognizer; 
import edu.cmu.sphinx.result.Result; 
import edu.cmu.sphinx.util.props.ConfigurationManager; 
import java.io.IOException; 
import java.util.logging.Level; 
import java.util.logging.Logger; 
import models.Tts; 

public class Speech { 

    public static void main(String[] args) { 
    ConfigurationManager cm; 

    if (args.length > 0) { 
     cm = new ConfigurationManager(args[0]); 
    } else { 
     ///tmp/helloworld.config.xml 
     cm = new ConfigurationManager(Speech.class.getResource("speech.config.xml")); 

    } 
    Recognizer recognizer = (Recognizer) cm.lookup("recognizer"); 
    recognizer.allocate(); 

    Microphone microphone = (Microphone) cm.lookup("microphone"); 
    if (!microphone.startRecording()) { 
     System.out.println("Cannot start microphone."); 
     recognizer.deallocate(); 
     System.exit(1); 
    } 

    System.out.println("Say: (Hello | call) (Naam | Baam | Caam | Some )"); 

    while (true) { 
     System.out.println("Start speaking. Press Ctrl-C to quit.\n"); 

     Result result = recognizer.recognize(); 

     if (result != null) { 
      String resultText = result.getBestFinalResultNoFiller(); 
      System.out.println("You said: " + resultText + '\n'); 

       Tts ts = new Tts(); 
       try { 
        ts.load(); 
        ts.say("Did you said: " + resultText); 
       } catch (IOException ex) { 

       } 
     } else { 
      System.out.println("I can't hear what you said.\n"); 
     } 
    } 
    } 
}` 

任何幫助,將不勝感激。

回答

0

Sphinx4不適合這項任務。它能夠識別語音,而不是實時識別個別聲音。你需要一個聲音識別器,以一個簡單的振幅檢測器形式。整體方法應該是這樣的:

  1. 錄製一小段音頻,比如100ms。
  2. 計算語音的幅度(簡單樣本的平方和)
  3. 顯示合適的圖像(嘴廣泛開放的響亮塊或在沉默關閉)。

在更高級的形式中,您可以識別元音並根據該元素調整人臉圖片。元音可以用GMM分類器識別。您甚至可以錄製多種情緒並實時顯示它們。實時是一個問題,因爲您的識別器需要非常短的分析時間,這使得這樣的系統設計複雜,這將是一個爲期幾個月的項目。你可以找到更詳細的描述here