How do I get all the audio properties from a speechsdk.AudioDataStream

Matt Ma 0 Reputation points
2023-11-24T01:53:06.0766667+00:00

I'm taking the results from the generated speech and eventually this will be streamed back to the client.

However, I want to know the audio properties of the audio_data returned but I can't find the list of property names on the stream (below). I assume I need that info consuming it on the client side. How do I get the property names avaiable.

		...
		result = self.speech_synthesizer.speak_text_async(text).get()
        stream = speechsdk.AudioDataStream(result)
        return stream
Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,554 questions
{count} votes

1 answer

Sort by: Most helpful
  1. navba-MSFT 20,635 Reputation points Microsoft Employee
    2023-11-24T05:29:31.6833333+00:00

    @Matt Ma Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
    I understand that your ask is about 'how to get all the audio properties from a speechsdk.AudioDataStream in Python speech SDK. . You can use the PropertyId enumeration defines various property identifiers that can be used with different components of the Azure Cognitive Services Speech SDK, including but not limited to AudioDataStream.
    Please see here.

    
    # Synthesize speech
    result = speech_synthesizer.speak_text_async("Hello, World!").get()
    
    # Create an AudioDataStream
    stream = speechsdk.AudioDataStream(result)
    
    # Get the properties
    properties = stream.properties
    
    # Iterate over the PropertyId enum
    for i in speechsdk.PropertyId:
        # Get each property's value
        value = properties.get_property(i)
        print(f"{i}: {value}")
    

    .
    Please refer sample code here.

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.

    0 comments No comments