2012-02-24 7 views
2

私は、録音されたオーディオファイルを電子メールで送信する音声ディクテーションアプリケーションをアンドロイドで開発しています。大規模なwavファイルを送信するのは難しいので、wavファイルを電子メールで簡単に送信できる適切な形式に変換することを考えています。wavオーディオファイルをDSSオーディオフォーマットに変換する

グーグルでは、.dssファイルのサイズが非常に小さく、簡単に送信できますが、wavファイルをdss形式に変換する方法はわかりません。あなたの答えはとても役に立ちます。

答えて

1

無料のオーディオコーデックですので、Speexの使用をお勧めします。 また、あなたはアンドロイドで使いやすいはずの無料のJavaライブラリがあります。

http://jspeex.sourceforge.net/

また、あなたが始める必要があるshich JSPeex SVNレポは、そこにあります。私はNDKをsetupedし、私のプロジェクトでのSpeexを使用したjavadoc http://jspeex.sourceforge.net/doc/index.html

+0

アンドロイドではjavax.soundはサポートされていないため、上記のリンクは私にとって役立ちません。 –

+0

エンコーダにバイト[] - sを投げることができます。http://jspeex.sourceforge.net/doc/org/xiph/speex/SpeexEncoder.html – devsnd

1

として http://jspeex.svn.sourceforge.net/viewvc/jspeex/main/trunk/player/src/main/java/org/xiph/speex/player/

Aswell:それはプレーヤーのためのいくつかのコード例とレコーダーを持っています。私は、波ファイルを正常にエンコードすることができますが、私はそれをデコードしようとすると、ファイルサイズが大きくなり続けます。私は、8000と16ビットのBIT、MONOのサンプルレートでオーディオを録音しました。

デコードのためのコードは以下のとおりである:

#include <jni.h> 
#include <stdio.h> 
#include "speex/speex.h" 

#define FRAME_SIZE 160 


void Java_com_m2_iSmartDm_ISmartDMActivity_spxDec(JNIEnv * env, jobject jobj, 
jstring dir1,jstring dir2) 
{ 
const char *inFile= (*env)->GetStringUTFChars(env,dir1,0); 
const char *outFile= (*env)->GetStringUTFChars(env,dir2,0); 
FILE *fin; 
FILE *fout; 
/*Holds the audio that will be written to file (16 bits per sample)*/ 
short out[FRAME_SIZE]; 
/*Speex handle samples as float, so we need an array of floats*/ 
float output[FRAME_SIZE]; 
char cbits[200]; 
int nbBytes; 
/*Holds the state of the decoder*/ 
void *state; 
/*Holds bits so they can be read and written to by the Speex routines*/ 
SpeexBits bits; 
int i, tmp; 

/*Create a new decoder state in narrowband mode*/ 
state = speex_decoder_init(&speex_nb_mode); 

/*Set the perceptual enhancement on*/ 
tmp=1; 
speex_decoder_ctl(state, SPEEX_SET_ENH, &tmp); 

fin = fopen(inFile, "r"); 
fout=fopen(outFile,"w"); 

speex_bits_init(&bits); 

while (1) 
{ 
/*Read the size encoded by sampleenc, this part will likely be 
different in your application*/ 
fread(&nbBytes, sizeof(int), 1, fin); 
if (feof(stdin)) 
break; 

/*Read the "packet" encoded by sampleenc*/ 
fread(cbits, 1, nbBytes, fin); 

/*Copy the data into the bit-stream struct*/ 
speex_bits_read_from(&bits, cbits, nbBytes); 

/*Decode the data*/ 
speex_decode(state, &bits, output); 

/*Copy from float to short (16 bits) for output*/ 
    for (i=0;i<FRAME_SIZE;i++) 
    out[i]=output[i]; 

/*Write the decoded audio to file*/ 
    fwrite(out, sizeof(short), FRAME_SIZE, fout); 

} 
/*Destroy the decoder state*/ 
speex_decoder_destroy(state); 
/*Destroy the bit-stream truct*/ 
speex_bits_destroy(&bits); 
fclose(fout); 
fclose(fin); 


} 

は私のコードで何か問題はありますか?それがなぜこのような大きなサイズで与えるのでしょうか?

+0

代わりに新しい質問をしてくださいこれを回して – devsnd