alphacep / vosk-android-demo

Offline speech recognition for Android with Vosk library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem reading .3gp files

noellemorris opened this issue · comments

Hi,

I'm attempting to adapt the File recognition code to files I record with Android's MediaRecorder class, and I'm having trouble getting it to work with code something like the following:

File outputDir = application.getFilesDir();
String fileName = "TEST.3gp" 

File audioFile = new File(outputDir + File.separator + fileName);

if (!audioFile.exists()) return;

Then I pass it to the sample code's recognizeFile method with:

InputStream ais = new FileInputStream(audioFile);

But the results in my callbacks are always empty. Is .3gp not supported by SpeechStreamService? If not, what file formats are supported? Or is there something else I'm doing wrong? (I never get an IOException, just empty hypothesis strings in the callbacks.)

Is .3gp not supported by SpeechStreamService?

No, you have to transcode.

If not, what file formats are supported?

Only raw PCM data.

Thank you for the quick response! I do have some additional questions:

If not, what file formats are supported?

Only raw PCM data.

Could you explain what you mean by this? Because your this sample app uses a .wav from the assets folder:

InputStream ais = getAssets().open(
"10001-90210-01803.wav");

So I'd like to understand why that works, if only raw PCM data is supported.

Thanks!