Skip to content

Commit 099af33

Browse files
Merge pull request #278597 from jackykang7777/patch-18
Add Using Custom Translation for Speech Translation and sample code
2 parents 23bb54d + 904e0ff commit 099af33

File tree

1 file changed

+21
-0
lines changed
  • articles/ai-services/speech-service/includes/how-to/translate-speech

1 file changed

+21
-0
lines changed

articles/ai-services/speech-service/includes/how-to/translate-speech/csharp.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,27 @@ var translationRecognizer = new TranslationRecognizer(speechTranslationConfig, a
405405

406406
For a complete code sample with the Speech SDK, see [speech translation samples on GitHub](https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/csharp/sharedcontent/console/translation_samples.cs#L472).
407407

408+
## Using custom translation in speech translation
409+
The custom translation feature in speech translation seamlessly integrates with the Azure Custom Translation service, allowing you to achieve more accurate and tailored translations. As the integration directly harnesses the capabilities of the Azure custom translation service, you need to use a multi-service resource to ensure the correct functioning of the complete set of features. For detailed instructions, please consult the guide on [Create a multi-service resource for Azure AI services](/azure/ai-services/multi-service-resource?tabs=windows&pivots=azportal).
410+
411+
Additionally, for offline training of a custom translator and obtaining a "Category ID," please refer to the step-by-step script provided in the [Quickstart: Build, deploy, and use a custom model - Custom Translator](/azure/ai-services/translator/custom-translator/quickstart).
412+
413+
```csharp
414+
// Creates an instance of a translation recognizer using speech translation configuration
415+
// You should use the same subscription key, which you used to generate the custom model before.
416+
// V2 endpoint is required for the “Custom Translation” feature. Example: "wss://westcentralus.stt.speech.microsoft.com/speech/universal/v2"
417+
418+
try (SpeechTranslationConfig config = SpeechTranslationConfig.fromEndpoint(URI.create(endpointUrl), speechSubscriptionKey)) {
419+
420+
// Sets source and target language(s).
421+
….
422+
423+
// Set the category id
424+
config.setCustomModelCategoryId("yourCategoryId");
425+
426+
….
427+
}
428+
```
408429

409430
[speechtranslationconfig]: /dotnet/api/microsoft.cognitiveservices.speech.speechtranslationconfig
410431
[audioconfig]: /dotnet/api/microsoft.cognitiveservices.speech.audio.audioconfig

0 commit comments

Comments
 (0)