[Speech to Text/Andoird-Java] How to pass PCM streaming data by AudioConfig.fromStreamInput(AudioInputStream)?

Anonymous
2020-07-28T07:28:20.897+00:00

1.We have PCM streaming data as input to be translated to text by speech SDK(speech:client-sdk:1.12.1).
2.Here's are our reference link: https://learn.microsoft.com/zh-tw/azure/cognitive-services/speech-service/how-to-use-codec-compressed-audio-input-streams?tabs=debian&pivots=programming-language-java
3.Assume we should pack our streaming PCM data with WAV head and pass to AudioConfig.fromStreamInput(AudioInputStream), but we have no idea how to wrap our WAV streaming data by AudioInputSteam/PullAudioInputStreamCallback. Is there any android/java sample codes?

Thanks for your help.

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,762 questions
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 46,746 Reputation points Microsoft Employee
    2020-07-29T13:18:08.003+00:00

    @HsuWeiYuan-8357 Yes, you can use PullAudioInputStreamCallback but it needs to be extended to read() and close() the audio stream before passing it to the SDK. The high level way to achieve this is documented here. Essentially the read and close are also available in the WavStream.java class reference.

    For the second question you need to ensure the PCM sample channel, bits/sample and samples/second are correctly defined as expected by the SDK i.e AudioStreamFormat.GetWaveFormatPCM()

    Then use the callback methods while defining the audioconfig and recognize it using the SDK recognizer.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.