This sample demonstrates how to translate speech with C# in a WPF application under the .NET Framework on Windows. Multiple languages to translate into can be selected; a language can be separately selected for voice output.
The sample runs on .NET Framework 4.6.1 (or above) on Windows.
- A subscription key for the Speech service. See Try the speech service for free.
- A Windows PC with a working microphone.
- Microsoft Visual Studio 2017, Community Edition or higher.
- The .NET desktop development workload in Visual Studio. You can enable it in Tools > Get Tools and Features.
- By building this sample you will download the Microsoft Cognitive Services Speech SDK. By downloading you acknowledge its license, see Speech SDK license agreement.
- Download the sample code to your development PC.
- Start Microsoft Visual Studio 2017 and select File > Open > Project/Solution.
- Navigate to the folder containing this sample, and select the solution file contained within it.
- Press Ctrl+Shift+B, or select Build > Build Solution.
To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
The app displays a graphical user interface (GUI).
- Use the Enter Subscription Key text field in the upper right to configure your subscription key.
- In the Region and Language fly-out on the left, configure the region that is associated with your subscription.
- In the same fly-out, pick your target language and a language for voice output.
- To start translating, select Start Translation.
- The app will then continuously translate utterance from your microphone.
- To stop translating, select Stop Translation.
Note: if you use the Save Key button, your subscription key will be written to an unencrypted file named
SubscriptionKey.txt
on your disk, inside .NET Isolated Storage. Please use the documentation if you'd like to locate and delete this file.