|
| 1 | +--- |
| 2 | +author: eric-urban |
| 3 | +manager: nitinme |
| 4 | +ms.service: cognitive-services |
| 5 | +ms.subservice: speech-service |
| 6 | +ms.topic: include |
| 7 | +ms.date: 04/06/2023 |
| 8 | +ms.author: eur |
| 9 | +ms.custom: devx-track-csharp |
| 10 | +--- |
| 11 | + |
| 12 | +Speech containers provide websocket-based query endpoint APIs that are accessed through the Speech SDK. By default, the Speech SDK uses the Speech service in the cloud. To use the container, you need to change the initialization method. |
| 13 | + |
| 14 | +> [!IMPORTANT] |
| 15 | +> When you use the Speech service with containers, be sure to use host authentication. If you configure the key and region, requests will go to the public Speech service. Results from the Speech service might not be what you expect. Requests from disconnected containers will fail. |
| 16 | +
|
| 17 | +::: zone pivot="programming-language-csharp" |
| 18 | +Change from using this Azure-cloud initialization call: |
| 19 | + |
| 20 | +```csharp |
| 21 | +var config = SpeechConfig.FromSubscription(...); |
| 22 | +``` |
| 23 | + |
| 24 | +To using this call with the container [host](/dotnet/api/microsoft.cognitiveservices.speech.speechconfig.fromhost): |
| 25 | + |
| 26 | +```csharp |
| 27 | +var config = SpeechConfig.FromHost( |
| 28 | + new Uri("http://localhost:5000")); |
| 29 | +``` |
| 30 | +::: zone-end |
| 31 | + |
| 32 | +::: zone pivot="programming-language-cpp" |
| 33 | +Change from using this Azure-cloud initialization call: |
| 34 | + |
| 35 | +```cpp |
| 36 | +auto speechConfig = SpeechConfig::FromSubscription(...); |
| 37 | +``` |
| 38 | + |
| 39 | +To using this call with the container [host](/cpp/cognitive-services/speech/speechconfig#fromhost): |
| 40 | + |
| 41 | +```cpp |
| 42 | +auto speechConfig = SpeechConfig::FromHost("http://localhost:5000"); |
| 43 | +``` |
| 44 | +::: zone-end |
| 45 | + |
| 46 | +::: zone pivot="programming-language-go" |
| 47 | +Change from using this Azure-cloud initialization call: |
| 48 | + |
| 49 | +```go |
| 50 | +speechConfig, err := speech.NewSpeechConfigFromSubscription(...) |
| 51 | +``` |
| 52 | + |
| 53 | +To using this call with the container host: |
| 54 | + |
| 55 | +```go |
| 56 | +speechConfig, err := speech.NewSpeechConfigFromHost("http://localhost:5000") |
| 57 | +``` |
| 58 | +::: zone-end |
| 59 | + |
| 60 | +::: zone pivot="programming-language-java" |
| 61 | +Change from using this Azure-cloud initialization call: |
| 62 | + |
| 63 | +```java |
| 64 | +SpeechConfig speechConfig = SpeechConfig.fromSubscription(...); |
| 65 | +``` |
| 66 | + |
| 67 | +To using this call with the container [host](/java/api/com.microsoft.cognitiveservices.speech.speechconfig#com-microsoft-cognitiveservices-speech-speechconfig-fromhost(java-net-uri)): |
| 68 | + |
| 69 | +```java |
| 70 | +SpeechConfig speechConfig = SpeechConfig.fromHost("http://localhost:5000"); |
| 71 | +``` |
| 72 | +::: zone-end |
| 73 | + |
| 74 | +::: zone pivot="programming-language-javascript" |
| 75 | +Change from using this Azure-cloud initialization call: |
| 76 | + |
| 77 | +```javascript |
| 78 | +const speechConfig = sdk.SpeechConfig.fromSubscription(...); |
| 79 | +``` |
| 80 | + |
| 81 | +To using this call with the container [host](/javascript/api/microsoft-cognitiveservices-speech-sdk/speechconfig#microsoft-cognitiveservices-speech-sdk-speechconfig-fromhost): |
| 82 | + |
| 83 | +```javascript |
| 84 | +const speechConfig = sdk.SpeechConfig.fromHost("http://localhost:5000"); |
| 85 | +``` |
| 86 | +::: zone-end |
| 87 | + |
| 88 | +::: zone pivot="programming-language-objectivec" |
| 89 | +Change from using this Azure-cloud initialization call: |
| 90 | + |
| 91 | +```objectivec |
| 92 | +SPXSpeechConfiguration *speechConfig = [[SPXSpeechConfiguration alloc] initWithSubscription:...]; |
| 93 | +``` |
| 94 | +
|
| 95 | +To using this call with the container [host](/objectivec/cognitive-services/speech/spxspeechconfiguration#initwithhost): |
| 96 | +
|
| 97 | +```objectivec |
| 98 | +SPXSpeechConfiguration *speechConfig = [[SPXSpeechConfiguration alloc] initWithHost:"http://localhost:5000"]; |
| 99 | +``` |
| 100 | +::: zone-end |
| 101 | + |
| 102 | +::: zone pivot="programming-language-swift" |
| 103 | +Change from using this Azure-cloud initialization call: |
| 104 | + |
| 105 | +```swift |
| 106 | +let speechConfig = SPXSpeechConfiguration(subscription: "", region: ""); |
| 107 | +``` |
| 108 | + |
| 109 | +To using this call with the container [host](/objectivec/cognitive-services/speech/spxspeechconfiguration#initwithhost): |
| 110 | + |
| 111 | +```swift |
| 112 | +let speechConfig = SPXSpeechConfiguration(host: "http://localhost:5000"); |
| 113 | +``` |
| 114 | +::: zone-end |
| 115 | + |
| 116 | +::: zone pivot="programming-language-python" |
| 117 | +Change from using this Azure-cloud initialization call: |
| 118 | + |
| 119 | +```python |
| 120 | +speech_config = speechsdk.SpeechConfig( |
| 121 | + subscription=speech_key, region=service_region) |
| 122 | +``` |
| 123 | + |
| 124 | +To using this call with the container [endpoint](/python/api/azure-cognitiveservices-speech/azure.cognitiveservices.speech.speechconfig): |
| 125 | + |
| 126 | +```python |
| 127 | +speech_config = speechsdk.SpeechConfig( |
| 128 | + host="http://localhost:5000") |
| 129 | +``` |
| 130 | +::: zone-end |
| 131 | + |
| 132 | +::: zone pivot="programming-language-rest" |
| 133 | +Set the host to `"http://localhost:5000"` |
| 134 | +::: zone-end |
| 135 | + |
| 136 | +::: zone pivot="programming-language-cli" |
| 137 | +For information about how to configure the Speech CLI, see [Get started with the Azure Speech CLI](../spx-basics.md?tabs=dockerinstall#download-and-install). |
| 138 | +::: zone-end |
| 139 | + |
0 commit comments