2

デスクトップ アプリケーションで Google の音声認識 API を使用できるかどうかを知りたいです。音声をファイルに変換して URL に送信する必要がある例を見てきました。しかし、私のアプリケーションではユーザーが自分の声を継続的に送信する必要があるため、少し面倒な作業になります。Google Speech API を使用する他の方法はありますか。スフィンクスの精度は非常に低く、辞書に新しい単語を追加する方法がわからず、辞書に追加しないと新しい単語を認識しないため、スフィンクスを使用することにあまり興味がありません。どんな助けでも大歓迎です。

4

1 に答える 1

1

アンビエントリスニングのことですか?私は実際に、Google Speech Recognition API を使用して音声アクティビティ検出アルゴリズムに取り組んでいます。アルゴリズムはまだ完成していませんが、音量と周波数の計算機を追加したので、その人が話していないときに Google にリクエストを送信する必要はありません。ソースコードへのリンクはこちらです。

https://github.com/The-Shadow/java-speech-api

(これは私が使用するものではありませんが、単純化されています。周波数しきい値の保持などを追加することもできます。このコードを一緒に投げたので、API のサンプル ブランチを見て動作する保証はありません。)

//package recognitionprocess;
//import org.jaudiotagger.audio.*;


import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;

import javax.sound.sampled.AudioFileFormat;

import com.darkprograms.speech.recognizer.GoogleResponse;
import com.darkprograms.speech.recognizer.Recognizer;

public class RecognitionMain {

    public static void main(String[] args)  {
        try{
        ambientListening();
        }
        catch(Exception e){
            e.printStackTrace();
        }
    }

    private static void ambientListening() throws Exception{

        String filename = "tarunaudio.wav";//Your Desired FileName
        MicrophoneAnalyzer mic = new MicrophoneAnalyzer(AudioFileFormat.Type.WAVE);
       mic.open();
        mic.captureAudioToFile(filename);
        final int THRESHOLD = 10;//YOUR THRESHOLD VALUE.
        int ambientVolume = mic.getAudioVolume();//
        int speakingVolume = -2;
        boolean speaking = false;
            for(int i = 0; i<1||speaking; i++){
                int volume = mic.getAudioVolume();
                System.out.println(volume);
                if(volume>ambientVolume+THRESHOLD){
                    speakingVolume = volume;
                    speaking = true;
                    Thread.sleep(1000);
                    System.out.println("SPEAKING");
                }
                if(speaking && volume+THRESHOLD<speakingVolume){
                     break;
                }
                Thread.sleep(200);//Your refreshRate
            }
              mic.close();
            //You can also measure the volume across the entire file if you want
            //to be resource intensive.
            if(!speaking){
                 ambientListening();
            }
        Recognizer rec = new Recognizer(Recognizer.Languages.ENGLISH_US);
        GoogleResponse out = rec.getRecognizedDataForWave(filename);
        System.out.println(out.getResponse());
        ambientListening();
    }
}
于 2013-09-15T18:29:29.917 に答える