dialogflow-java-client-v2 icon indicating copy to clipboard operation
dialogflow-java-client-v2 copied to clipboard

Send byte array from audio recorded with Chrome (MediaRecorder API)

Open crisro96 opened this issue 6 years ago • 0 comments

I am recording an audio message in Chrome (and Firefox) using the MediaRecorder API. The options for the stream are set to webm/opus for Chrome and ogg/opus for Firefox I successfully saved files from both browsers on my PC and can be played using VLC. On my Java application I read the audio files as byte arrays and straight up run the provided sample for audio to dialogflow with the following change:

var audioEncoding = AudioEncoding.AUDIO_ENCODING_OGG_OPUS;
			var sampleRateHz = 48000; // 8000, 12000, 16000, 24000, 48000
			var inputAudioConfig = InputAudioConfig.newBuilder()
                                                               .setAudioEncoding(audioEncoding)
                                                               .setLanguageCode("en-US")
                                                               .setSampleRateHertz(sampleRateHz)
                                                               .build();

Both audio files are a recording saying "This is a test". The Firefox version will return the default response from my DialogFlow agent, while the Chrome version will simply return an empty response (not NULL, just doesn't contain any data - see screenshot).

OS: Windows; Java version: 10

desktop screenshot 2018 06 09 - 02 30 32 85

Edit: this also seems to happen with a .wav file with AudioEncoding set to AUDIO_ENCODING_LINEAR16;

crisro96 avatar Jun 08 '18 23:06 crisro96