Azure Real Time Speech To Text fails to take input from Blob URL

Indira Priyadarshini 60 Reputation points
2024-02-23T06:12:46.4266667+00:00

I have implemented Azure Real Time Speech to Text using Speech SDK in Python for pre recorded audio files. It works fine when the input audio is on my machine. But fails when I give the input as the Blob url containing the audio. Please help!

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,777 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,904 questions
{count} votes

Accepted answer
  1. Divakarkumar-3696 375 Reputation points
    2024-02-23T10:00:42.9233333+00:00

    Hi Indira,

    Thanks for sharing the code,I see you are using filename parameter to specify the BlobUrl. Instead make sure it is done in the below way

    • Download audio file from Azure blob storage using container_client and write to temporary file on disk
    • Pass the temporary file to the filename parameter in your above code.

    Process audio :

     
     try:
            with open(filename, "wb") as audio_file:
                audio_data = container_client.download_blob(filename).readall()
                audio_file.write(audio_data)
            result = speechsdk.audio.AudioConfig(filename=filename, lang_id, speech_config)
        finally:
            os.remove(filename)
    

    Please 'Accept as answer' if it helped so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.