-2

I would like to activate the function that automatically detects the spoken language. The development language uses C#, but there was no sample code on the website. Please let me know if you know how to write.

Sam Axe
  • 33,313
  • 9
  • 55
  • 89
  • You need to send a request with JSON to the API endpoint that help page links to https://cloud.google.com/speech-to-text/docs/reference/rest/v1p1beta1/speech/recognize – Boris Verkhovskiy Oct 04 '19 at 00:57

1 Answers1

0

Currently the service you want to use is in pre-release state attacht to the speech_v1p1beta1 version of the Speech to Text API, there is no implementation for auto detect the language in C# yet but an alternative to that you can make an HTTP Request to the API, in order to accomplish that you can use a C#'s HTTP Request library from a third-party like RestSharp (You can find an example on how to make a request with this library in here: http://restsharp.org/) with the structure like Speech to Text documentation indicates(e. g.):

curl -s -H "Content-Type: application/json" \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    https://speech.googleapis.com/v1p1beta1/speech:recognize \
    --data '{
    "config": {
        "encoding":"LINEAR16",
        "languageCode": "en-US",
        "alternativeLanguageCodes": ["fr-FR", "de-DE"],
        "model": "command_and_search"
    },
    "audio": {
        "uri":"gs://cloud-samples-tests/speech/commercial_mono.wav"
    }
}'

If the request is succesful you'll recive a "200 OK" status indicating that the request was successul along with a JSON format with the results(e. g.):

{
  "results": [
    {
      "alternatives": [
        {
          "transcript": "hi I'd like to buy a Chromecast I'm ..."
          "confidence": 0.9466864
        }
      ],
      "languageCode": "en-us"
    },
    {
      "alternatives": [
        {
          "transcript": " let's go with the black one",
          "confidence": 0.9829583
        }
      ],
      "languageCode": "en-us"
    },
  ]
}

You can find more about how to make HTTP Requests to the Speech to Text API in the follow documentation on the "PROTOCOL" tab: https://cloud.google.com/speech-to-text/docs/multiple-languages#speech-multi-lang-protocol

Messier_31
  • 183
  • 6