Javaを使用して3GPファイルからDTMF数字を検出する方法があるのだろうかと思っていました。3GPファイルからDTMF数字を検出する
0
A
答えて
1
TarsosDSPを使用すると、DTMFをJavaでデコードできます。これの実装例はthis blogpostにあります。
3GPからオーディオをデコードする方法は、その中で使用されるオーディオコーデックによって異なります。
0
私はこのセンテンスの下にポストしようとしているコードにこのようなライブラリ "TarsosDSP"を使用することは可能ですか?
はいの場合はどうですか?
私は本当に興味があり、私は理解したい!
import java.io.IOException;
import org.JMathStudio.DataStructure.Complex;
import org.JMathStudio.DataStructure.Cell.Cell;
import org.JMathStudio.DataStructure.Cell.CellTools;
import org.JMathStudio.DataStructure.Vector.CVector;
import org.JMathStudio.DataStructure.Vector.Vector;
import org.JMathStudio.DataStructure.Vector.VectorStack;
import org.JMathStudio.Exceptions.DimensionMismatchException;
import org.JMathStudio.Exceptions.IllegalArgumentException;
import org.JMathStudio.Exceptions.UnSupportedImageFormatException;
import org.JMathStudio.SignalToolkit.GeneralTools.SignalUtilities;
import org.JMathStudio.SignalToolkit.TransformTools.FourierSet.FFT1D;
import org.JMathStudio.SignalToolkit.Utilities.SignalGenerator;
public class DTMF_Demo {
static int [] freqTableRow = {
697, 770, 852, 941
} ;
static int [] freqTableCol = {
1209, 1336, 1477
} ;
static char [][] dialKey = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
} ;
static int fs = 4000 ; // Sampling Rate
static float noiseLevel = 0.2f ; // Amplitude of the noise signal before normalization
private String dialKeyString ; // The dial key sequence generated
// This is the method that generate the dial key sequence signal
public float [] dtmfDial() throws IllegalArgumentException
{
VectorStack numberStack = new VectorStack() ; // A temporary storage for a list of signal vectors
int totalLength = 0 ; // Total length of the dial key sequence signal generated
int row ; // Row index into the frequency table
int col ; // Column index into the frequency table
int length ; // Length of a dial key signal
int numDigit ; // Number of keys to generate for a dial key sequence
int pauseLength ; // Length of pause signal
int i, j, k ; // Looping variables
float normFactor ; // Normalization factor for dial key sequence
normFactor = 2.0f + noiseLevel ;
dialKeyString = new String("") ;
numDigit = Math.round((float) (5.0f + Math.random() * 11.0f)) ;
for(i = 0; i < numDigit; i++)
{
row = Math.round((float) (Math.random() * 3.99 - 0.49)) ;
col = Math.round((float) (Math.random() * 2.99 - 0.49)) ;
length = Math.round((float) (fs/2 + Math.random() * 1.5 * fs)) ;
pauseLength = Math.round((float) (fs/4 + Math.random() * 0.75 * fs)) ;
Vector tone = SignalGenerator.cosine(freqTableRow[row], fs, 0.0f, length+pauseLength) ;
Vector tone2 = SignalGenerator.cosine(freqTableCol[col], fs, 0.0f, length+pauseLength) ;
Vector noise = SignalGenerator.random(length+pauseLength) ;
dialKeyString += dialKey[row][col] ; // Look up actual key dialed
totalLength += (length+pauseLength) ;
// Sum the two sinusoids with addition of noise
for(j = 0; j < length; j++)
{
tone.accessVectorBuffer()[j] += tone2.accessVectorBuffer()[j] ;
tone.accessVectorBuffer()[j] += ((2.0f * noiseLevel) * noise.accessVectorBuffer()[j] - noiseLevel);
tone.accessVectorBuffer()[j] /= normFactor ;
}
// Inject pause and noise signals
for(j = length; j < length + pauseLength; j++)
{
tone.accessVectorBuffer()[j] = ((2.0f * noiseLevel) * noise.accessVectorBuffer()[j] - noiseLevel) ;
tone.accessVectorBuffer()[j] /= normFactor ;
}
numberStack.addVector(tone) ; // Add the dial key signal into the stack of signal vectors
}
float [] dtmfSignal = new float[totalLength] ; // Array of floats to serve as the output dial key sequence signal
Vector [] numberVectorArray = numberStack.accessVectorArray();
// Concatenate the dial key signals to form the output dial key sequence signal
k = 0 ;
for(i = 0; i < numberStack.size(); i++)
{
for(j = 0; j < numberVectorArray[i].length(); j++)
{
dtmfSignal[k] = numberVectorArray[i].accessVectorBuffer()[j] ;
k++ ;
}
}
return dtmfSignal ;
}
public Boolean dialKeyStringMatch(String decodedKeyString)
{
return dialKeyString.equals(decodedKeyString) ;
}
public String getDialString()
{
return dialKeyString ;
}
public static void main(String[] args) throws IOException, UnSupportedImageFormatException, DimensionMismatchException
{
// TODO Auto-generated method stub
DTMF_Demo demo = new DTMF_Demo() ;
DTMF_Decode decoder = new DTMF_Decode() ;
try
{
int correct = 0 ;
int totalCount = 1 ;
for(int i = 0; i < totalCount; i++)
{
// Generate Dial Key Sequence Signal
float [] dtmfSignal = demo.dtmfDial() ;
// Call your implemented dtmfAnalyse method and obtain decoded key string
String decodedKeyString = decoder.dtmfAnalyse(dtmfSignal, fs) ;
// Compare your decoded key sequence with the ground truth
if(demo.dialKeyStringMatch(decodedKeyString))
{
correct++ ;
}
else
{
// Print out incorrectly decoded dial key sequence
System.out.println(demo.getDialString() + " (original) != " + decodedKeyString + " (decoded)") ;
}
}
System.out.println(correct + " out of " + totalCount + " are correct.") ;
}
catch (Exception e)
{
e.printStackTrace() ;
}
}
}
関連する問題
- 1. 3gpからwavファイルへAndroid
- 2. WAVファイルからDTMFをデコードする
- 3. オプションで無視するDTMF数字?
- 4. 3gpファイルをアップロードする方法
- 5. .wavファイルからDTMFを調べようとしています
- 6. matlabからファイル名の数字を抽出するには?
- 7. ダーウィンは、レールから3gpファイルをアップロードすることができません
- 8. DTMFオプションがivrボットアプリケーションで複数の数字を認識する方法
- 9. 英数字の文字列から数字を抽出する
- 10. 3gpのmoov原子を1つのファイルから別のファイルにコピー
- 11. 数字と文字で文字列を検出する
- 12. Python - 複数のファイルから複数の文字列のテキストを抽出する
- 13. ルア - 3gpファイルをraw(またはwav)に変換しますか?
- 14. 文字列から数字と文字を抽出するR
- 15. Javaのテキストファイルから文字列から数字を検索
- 16. Java/Androidで3GPビデオファイルの長さを抽出する
- 17. Python DTMFエンコーダ - 特殊文字を無視する
- 18. ファイル内の複数の文字列(ファイルから)を検索し、行を印刷
- 19. Javaで3gpファイルを再生するには?
- 20. flvストリームデコード、3gpエンコード
- 21. 文字列ベクトルから数字のベクトルを抽出する
- 22. Swiftのテキストファイルから数字と文字を抽出する
- 23. 画像から数字と文字を抽出する
- 24. R:文字列から数字を抽出する
- 25. テキストから文字列と数字を抽出する
- 26. テキストの文字列から数字を抽出する - Excel
- 27. Cの文字列から数字を抽出する
- 28. ファイルから文字列を検索して選択する
- 29. 配列から文字列を検索するファイル
- 30. ファイル名/文字列のシーケンスの検出