vosk-android-demo icon indicating copy to clipboard operation
vosk-android-demo copied to clipboard

Problem reading .3gp files

Open noellemorris opened this issue 2 years ago • 2 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.)

noellemorris avatar Mar 25 '22 17:03 noellemorris

Is .3gp not supported by SpeechStreamService?

No, you have to transcode.

If not, what file formats are supported?

Only raw PCM data.

nshmyrev avatar Mar 25 '22 23:03 nshmyrev

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:

https://github.com/alphacep/vosk-android-demo/blob/248f40de2449a6185a9e7b3fb9d985aa5221312c/app/src/main/java/org/vosk/demo/VoskActivity.java#L212-L213

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

Thanks!

noellemorris avatar Mar 28 '22 13:03 noellemorris