Skip to content

Commit 10910f0

Browse files
committed
adding examples
1 parent 994ff62 commit 10910f0

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

articles/cognitive-services/Speech-Service/includes/speech-to-text-container-query-endpoint.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ to this call using the container [host](https://docs.microsoft.com/dotnet/api/mi
3131
var config = SpeechConfig.FromHost(
3232
new Uri("ws://localhost:5000"));
3333
```
34+
3435
# [Python](#tab/python)
3536

3637
Change from using this Azure-cloud initialization call:
@@ -47,4 +48,34 @@ speech_config = speechsdk.SpeechConfig(
4748
host="ws://localhost:5000")
4849
```
4950

51+
To call sentiment analysis:
52+
53+
> [!NOTE]
54+
> You can send requests for either "detailed" or "simple" responses.
55+
56+
```python
57+
speech_config.set_service_property(
58+
name='speechcontext-PhraseOutput.Detailed.Extensions',
59+
value='["Sentiment"]',
60+
channel=speechsdk.ServicePropertyChannel.UriQueryParameter
61+
)
62+
speech_config.set_service_property(
63+
name='speechcontext-phraseDetection.sentimentAnalysis.modelversion',
64+
value='latest',
65+
channel=speechsdk.ServicePropertyChannel.UriQueryParameter
66+
)
67+
```
68+
69+
### Disable Sentiment analysis in the API response
70+
71+
To disable sentiment analysis from appearing in the API response, regardless of other properties specified:
72+
73+
```python
74+
speech_config.set_service_property(
75+
name='speechcontext-phraseDetection.sentimentanalysis.enabled',
76+
value='false',
77+
channel=speechsdk.ServicePropertyChannel.UriQueryParameter
78+
)
79+
```
80+
5081
***

articles/cognitive-services/Speech-Service/speech-container-howto.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,27 @@ This command:
254254
* Exposes TCP port 5000 and allocates a pseudo-TTY for the container.
255255
* Automatically removes the container after it exits. The container image is still available on the host computer.
256256

257+
### Call sentiment analysis with the speech container
258+
259+
Starting in v2.2.0 of the speech services container, you can call v3 of the Sentiment Analysis API on the speech-to-text output. To call sentiment analysis, you will need a Text Analytics resource endpoint. For example:
260+
* `https://westus2.api.cognitive.microsoft.com/text/analytics/v3.0-preview.1/sentiment`
261+
* `https://localhost:5000/text/analytics/v3.0-preview.1/sentiment`
262+
263+
If you're accessing a Text analytics endpoint in the cloud, you will need a key. If you're running Text Analytics locally, you may not need to provide this.
264+
265+
The key and endpoint are passed to the Speech container as arguments, as in the following example.
266+
267+
```bash
268+
docker run -it --rm -p 5000:5000 \
269+
containerpreview.azurecr.io/microsoft/cognitive-services-speech-to-text:latest \
270+
Eula=accept \
271+
Billing={ENDPOINT_URI} \
272+
ApiKey={API_KEY} \
273+
CloudAI:SentimentAnalysisSettings:TextAnalyticsHost={TEXT_ANALYTICS_HOST} \
274+
CloudAI:SentimentAnalysisSettings:SentimentAnalysisApiKey={SENTIMENT_APIKEY}
275+
```
276+
277+
257278
# [Custom Speech-to-text](#tab/cstt)
258279

259280
The *Custom Speech-to-text* container relies on a custom speech model. The custom model has to have been [trained](how-to-custom-speech-train-model.md) using the [custom speech portal](https://speech.microsoft.com/customspeech).

0 commit comments

Comments
 (0)