It’s been around 6 years since I last wrote about the Azure Translator Services. Since 2015, the API has been updated from XML to JSON and re-organised under the Cognitive Services branding. Additionally, functionality has been broken down into different resources to help control access and provide increased flexibility around service delivery and billing.
This week, I’ve updated the original blog content and shared new classes that work with the latest API’s. The security configuration has been updated to reflect the latest regions and the code released onto Github
The readme.md provides details about the prerequisites for using the Azure Services, including the steps to follow to find the access keys when you set up your subscriptions and resources on the Azure portal.
You can see the updated blog entry covering the services in more detail at https://delphiaball.co.uk/2021/07/30/how-to-use-azure-cloud-cognitive-services/
Azure Cloud – Translator Services
Azure Cloud – Text to Voice
Azure Cloud – Voice to Text
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
Good work, thank you.
The Azure-Cognitive-Services example, from Github, doesn’t work.
Proposed solution: In Azure.API3.Connection.pas in the function TAzureToken.GetToken, before RESTRequest.Execute, add a line “RESTRequest.AddAuthParameter (‘Ocp-Apim-Subscription-Key’, SubscriptionKey, pkHTTPHEADER);”
Thanks for the heads-up Domian. I’ve added this as a pull request on the original repo https://github.com/DelphiABall/Azure-Cognitive-Services/pull/5. It should get merged by the repo owner in due course. 👍
I’ll remove the push. The reason being there are two ways to authenticate, one uses the Ocp-Apim-Subscription-Key for each connection, the other fetches a token that is then used for multiple API calls. This is a more aligned with OAuth2 configurations and reduces risk of sharing our private key in every call. It also means you can share the same service token between multiple objects, making updating / switching easier.
If you look at the sample, you need to create an instance of TAzureToken and then set the Subscription key property of that object. You then assign the Token object to any of the class instances that you create that call the API.
😀👍
Hello,
I also tried the Demo from Github without success.
I checked it out, compiled it, supply Region and Key, click Test -> 401.
If I made changes like Domian suggested, click on Test works well.
What’s wrong with my and Domians Source?
Greetings Luigi
Hello,
I have he same issue like Domian with the Demo form Github.
I enter Area and Code, click on “Test” and receive a 401 Error.
After changing the Code like Domian suggested, everything is fine.
What is going wrong?
Greetings