Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bbonkr/sample.azure.translator

Sample app for Azure Translator
https://github.com/bbonkr/sample.azure.translator

Last synced: 25 days ago
JSON representation

Sample app for Azure Translator

Awesome Lists containing this project

README

        

# Sample codes for Azure Translator

[Azure Translator](https://azure.microsoft.com/services/cognitive-services/translator/) is an AI service for real-time text translation.

## Requirements

1. Make sure to create Azure Translator resource.
2. Make sure to have access your azure translator subscription key.
Go to your azure translator resource then click key and endpoint menu.

## Configure

Edit src\Sample.Azure.Translator.App\appsettings.json file.

```json
{
"Translator": {
"Endpoint": "endpoint here",
"SubscriptionKey": "subscription key here",
"Region": "region here",
"ResourceName": "name of resource"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
```

## Run

Sample app translate input text or file to en, ru, ja.

### Arguments

- `--to=`: (required) Languages to translate. Comma separated string. e.g.) --to=en,ko,ja
- `--from=`: (optional) Input text language.
- `--html`: (optional) Input text is html.
- `--each-language`: (optional) Request to translate each language

### Use text file

```bash
$ cd src/Sample.Azure.Translator.App
$ dotnet run -- ../../samples/sample.txt --from=ko --to=en,ja,es
Result: {
"Data": [
{
"DetectedLanguage": {
"Language": "ko",
"Score": 0.96
},
"SourceText": null,
"Translations": [
{
"Text": "If you are using multiple service resources in the Negative Service. This allows you to authenticate requests for multiple services using a single secret key. ",
"Transliteration": null,
"To": "en",
"Alignment": null,
"SentLen": null
},
{
"Text": "ネガティブ サ?ビスで複?のサ?ビス リソ?スを使用している場合。これにより、?一の秘密キ?を使用して複?のサ?ビスの要求を認?できます。",
"Transliteration": null,
"To": "ja",
"Alignment": null,
"SentLen": null
},
{
"Text": "Если вы используете несколько ресурсов службы в отрицательной службе. Это позволяет проверить подлинность запросов на несколько служб с помощью одного секретного ключа. ",
"Transliteration": null,
"To": "ru",
"Alignment": null,
"SentLen": null
}
]
}
],
"StatusCode": 200,
"Message": ""
}
```

### Use console input

```bash
$ cd src/Sample.Azure.Translator.App
$ dotnet run -- --to=en,ja,ru
Please type to want translation then press a return key (or enter key).
If want to exit this app, press 'ctrl' + 'c'.
Input text:
안녕하세요. 고마워요.
Result: {
"Data": [
{
"DetectedLanguage": {
"Language": "ko",
"Score": 1
},
"SourceText": null,
"Translations": [
{
"Text": "Hello. Thank you.",
"Transliteration": null,
"To": "en",
"Alignment": null,
"SentLen": null
},
{
"Text": "こんにちは。ありがとうございました。",
"Transliteration": null,
"To": "ja",
"Alignment": null,
"SentLen": null
},
{
"Text": "Привет. Спасибо.",
"Transliteration": null,
"To": "ru",
"Alignment": null,
"SentLen": null
}
]
}
],
"StatusCode": 200,
"Message": ""
}
```

### Use html file

```bash
$ cd src/Sample.Azure.Translator.App
$ dotnet run -- --html --to=ko ../../samples/sample.html
Result: {
"Data": [
{
"DetectedLanguage": {
"Language": "ko",
"Score": 0.95
},
"SourceText": null,
"Translations": [
{
"Text": "

\r\n

Look back to 2020.

\r\n


\r\n \r\n \r\n Technology Stack

\r\n


\r\n
\r\n \r\n
.NET 5

\r\n

You are transferring your previous .NET Core 2.x to 3.x application to .NET 5.

\r\n

I'm going to stay with you.

\r\n


\r\n \r\n \r\n React

\r\n

In 2020, he was responsible for web front-end work for almost most projects.

\r\n

We've used React, and we're going to continue reacting in the future.

\r\n


\r\n \r\n \r\n Node.js

\r\n

Unless it's a big project, nodejs is thought of as a good backend platform.

\r\n

express.js, and now to take advantage of nestjs, \r\n I'm studying.

\r\n

We also use it to create cross-platform CLI tools.

\r\n


\r\n \r\n \r\n Typescript

\r\n

Code that needs to be written in JavaScript now feels more comfortable using Typescript.

\r\n

It's inconvenient to write a little more code, and it's inconvenient to configure transfiles, but it's more convenient when writing code.

\r\n

I'm thinking of continuing to use Typescript.

\r\n


\r\n \r\n \r\n Container

\r\n

I'm learning container skills as a docker, and I need to learn other containers a little bit.

\r\n

You have transferred a web application that operates on AWS Lightsail to use a container.

\r\n


\r\n \r\n \r\n React Native

\r\n

Looking back on 2019, there were things I wanted to do in 2020, and there's a change of mind.

\r\n

I think it's a good technology when writing a mobile app that consists of simple features.

\r\n

However, it was very difficult if you needed a feature or native feature that you couldn't implement yourself, and you searched for a package to use it and you couldn't find the code that was implemented.

\r\n

The other platforms would be the same, but I thought it would be very difficult to access them easily.

\r\n

Rather than taking it to the main, this technology should only be used when implementing a simple mobile app.

\r\n


\r\n \r\n
\r\n
2020 Stories

\r\n

We worked with the startup team.

\r\n

Some projects have abandoned their projects because the team's service plans have not been organized, while some have not yet started service as a social statement.

\r\n

And I started working part-time.

\r\n

When the person planning the service organized the problem with a small startup team that was not organized, the planner continued to give the idea.\r\n The service concept has continued to change.\r\n After a while, the team abandoned the service because it seemed difficult to implement it.

\r\n

Teams that have not yet started service in the final stages are being delayed from starting service due to COVID-19.

\r\n

In addition, the team I contacted on Facebook Chat suggested part-time work.

\r\n


\r\n \r\n \r\n Applications

\r\n

A list of applications published in 2020.

\r\n \r\n


\r\n \r\n \r\n In 2021,

\r\n

I want to find work as slowly as I do now, and I want to do it.

\r\n

I want to keep up with the good people.

\r\n

You must purchase a mac with Apple silicon.\r\n We look forward to presenting more high-performance technology than M1.

\r\n

We are waiting for that time to become safe from COVID-19.\r\n There are many people I would like to meet, and I would like to see you.

\r\n
",
"Transliteration": null,
"To": "en",
"Alignment": null,
"SentLen": null
}
]
}
],
"StatusCode": 200,
"Message": ""
}
```