dialogflow-java-client-v2
dialogflow-java-client-v2 copied to clipboard
Send byte array from audio recorded with Chrome (MediaRecorder API)
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
Edit: this also seems to happen with a .wav file with AudioEncoding set to AUDIO_ENCODING_LINEAR16;