azure speech to text using azure AI foundry

In this example, we will try to test out Azure speech to text by. First we need to create an Azure foundry project. Go to Azure portal then on the left, select  "Use with Foundry" and create a foundry resource.]

After you created it, it will look something like this.



After it is completed, click on the link to goto Azure foundry, then select Build -> Model -> Azure Speech speech to text. 



And you will get some endpoints and keys that you can use. Or if you're not doing any coding, then you can just upload a file or click on "Start recording" for a demo. 

The beauty of it is, you can see it working in real-time


Then it can return JSON as an output. And finally you can use code to interact with it 



Example of pre-generated c# code look like this.


using Microsoft.CognitiveServices.Speech;
using Microsoft.CognitiveServices.Speech.Audio;

class Program
{
    static async Task Main(string[] args)
    {
        // Set up the speech config using resource endpoint
        var endpointUrl = Environment.GetEnvironmentVariable("AZURE_SPEECH_ENDPOINT")
            ?? "https://my-fdry-ai-aue-test.cognitiveservices.azure.com/";
        var speechKey = Environment.GetEnvironmentVariable("AZURE_SPEECH_KEY")
            ?? "<your-api-key>";

        var speechConfig = SpeechConfig.FromEndpoint(
            new Uri(endpointUrl),
            speechKey
        );

        // Create a recognizer with microphone input
        using var audioConfig = AudioConfig.FromDefaultMicrophoneInput();
        using var recognizer = new SpeechRecognizer(speechConfig, audioConfig);

        // Event handlers
        recognizer.Recognized += (s, e) =>
        {
            Console.WriteLine($"Recognized: {e.Result.Text}");
        };

        recognizer.Recognizing += (s, e) =>
        {
            Console.WriteLine($"Recognizing: {e.Result.Text}");
        };

        // Start continuous recognition
        await recognizer.StartContinuousRecognitionAsync();
        Console.WriteLine("Say something...");
       
        // Keep the program running
        Console.ReadKey();
        await recognizer.StopContinuousRecognitionAsync();
    }
}








Comments

Popular posts from this blog

vllm : Failed to infer device type

android studio kotlin source is null error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20