microsoft / cognitive-services-speech-sdk-js

Microsoft Azure Cognitive Services Speech SDK for JavaScript
Other
267 stars 101 forks source link

[Bug]: How to use text streaming #850

Open stevemao opened 3 months ago

stevemao commented 3 months ago

What happened?

On the API docs, I found https://learn.microsoft.com/en-au/azure/ai-services/speech-service/how-to-lower-speech-synthesis-latency?pivots=programming-language-python#text-streaming

But I do not see speechsdk.SpeechSynthesisRequestInputType.TextStream in this library. How do achieve text streaming using this library?

Version

1.36.0 (Latest)

What browser/platform are you seeing the problem on?

Node, browsers, reactjs

Relevant log output

Key steps
Create a text stream request: Use speechsdk.SpeechSynthesisRequestInputType.TextStream to initiate a text stream.

Set global properties: Adjust settings such as output format and voice name directly, as the feature handles partial text inputs and doesn't support SSML. Refer to the following sample code for instructions on how to set them. OpenAI text to speech voices aren't supported by the text streaming feature. See this language table for full language support.

Python

Copy
# set a voice name
speech_config.speech_synthesis_voice_name = "en-US-AvaMultilingualNeural"
Stream your text: For each text chunk generated from a GPT model, use request.input_stream.write(text) to send the text to the stream.

Close the stream: Once the GPT model completes its output, close the stream using request.input_stream.close().
maisterr commented 3 months ago

Faced the same problem, it would be useful to know if this is planned to be added to the JS SDK soon

BrianMouncer commented 3 months ago

@yulin-li can you comment on plans to add TextStreaming to JS SDK?

yulin-li commented 3 months ago

Thanks for using the text streaming feature. We need the sync internally for this feature plan. I will reply here once it's clear.

akshay-jam commented 1 month ago

@yulin-li any update on when this feature will be available in JS SDK

akshay-jam commented 1 month ago

@BrianMouncer @yulin-li any update on when this feature will be available in JS SDK