0
wit.aiの音声をテキストに変換しようとしていますので、録音した音声をwhatsappからテキストに変換することができます。wit.aiとoggファイルの使い方
wit.aiは、Content-Typeヘッダーに 'audio/wav'、 'audio/mpeg3'、 'audio/ulaw'、 'audio/raw'をサポートしています。 audio/rawを使用する場合は、エンコーディング、ビット、レート、エンディアンも指定する必要があります。
whatsappから取得しているファイルは.oggです。
彼らは私がすべての可能なバリエーションを持つオーディオ/生を試みたこの種類のファイルをサポートしていませんが、私は同じエラーになっておくので:
{
"error" : "Bad request",
"code" : "bad-request"
}
私は別の種類を試してみてください(オーディオ/ wavファイルのために例)私は理にかなって別のエラー取得しています:私はやっているファイルの取得について
{
"error" : "Mismatch between the provided content-type and the bytes you sent.\nAre you sure it's a valid sound file?",
"code" : "content-type-mismatch"
}
を:
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
Log.w("myapp", "got the intent");
if (Intent.ACTION_SEND.equals(action) && type != null) {
audioUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
を
私がやっているファイルを読むには:
InputStream inputStream = getContentResolver().openInputStream(uri);
String type = getContentResolver().getType(uri);
Log.w("myapp", "type of file: " + type);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream fis = getContentResolver().openInputStream(uri);
try {
byte[] buf = new byte[1024];
int n;
while (-1 != (n = fis.read(buf)))
baos.write(buf, 0, n);
} catch (Exception e) {
e.printStackTrace();
}
Log.w("myapp", Integer.toString(baos.toByteArray().length));
return baos.toByteArray();
私は間違っていますか?
このライブラリをお手伝いできますか?どのようにしてoggをピンに変換することができますか? –