You can send recognizing text with SDK only as portal way is not supported from Real time speech detection.
Attached Java SDK implementation
const sdk = require("microsoft-cognitiveservices-speech-sdk");
const fetch = require("node-fetch");
const speechSubscriptionKey = "YourSpeechServiceKey";
const serviceRegion = "YourServiceRegion";
const functionUrl = "https://<YourFunctionApp>.azurewebsites.net/api/<FunctionName>";
const audioConfig = sdk.AudioConfig.fromDefaultMicrophoneInput();
const speechConfig = sdk.SpeechConfig.fromSubscription(speechSubscriptionKey, serviceRegion);
const speechRecognizer = new sdk.SpeechRecognizer(speechConfig, audioConfig);
speechRecognizer.recognizing = (s, e) => {
console.log(`RECOGNIZING: Text=${e.result.text}`);
};
speechRecognizer.recognized = async (s, e) => {
if (e.result.reason === sdk.ResultReason.RecognizedSpeech) { console.log(`RECOGNIZED: Text=${e.result.text}`);
await sendToAzureFunction(e.result.text);
} else if (e.result.reason === sdk.ResultReason.NoMatch) { console.log("NOMATCH: Speech could not be recognized.");
}
};
speechRecognizer.canceled = (s, e) => {
console.log(`CANCELED: Reason=${e.reason}`);
if (e.reason === sdk.CancellationReason.Error) {
console.log(`"CANCELED: ErrorCode=${e.errorCode}`);
console.log(`"CANCELED: ErrorDetails=${e.errorDetails}`); console.log("CANCELED: Did you set the speech resource key and region values?");
}
speechRecognizer.stopContinuousRecognitionAsync();
};
speechRecognizer.sessionStopped = (s, e) => { console.log("\n Session stopped event."); speechRecognizer.stopContinuousRecognitionAsync(); };
async function sendToAzureFunction(recognizedText) {
try {
const response = await fetch(functionUrl, { method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ text: recognizedText })
});
console.log(`Status Code: ${response.status}`);
} catch (error) {
console.error("Error sending to Azure Function:", error);
}
}
Kindly refer below link: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/how-to-recognize-speech?pivots=programming-language-javascript
Thank You,