error in quickstart to the Cloud Text-to-Speech API

179 views
Skip to first unread message

Sss Kkk

unread,
Oct 11, 2018, 8:53:22 AM10/11/18
to Google Cloud Developers
followed this page:


successfully installed google cloud shell but issuing the command

curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
 
-H "Content-Type: application/json; charset=utf-8" \
 
--data "{
    'input':{
      'text':'Android is a mobile operating system developed by Google,
         based on the Linux kernel and designed primarily for
         touchscreen mobile devices such as smartphones and tablets.'
    },
    'voice':{
      'languageCode':'en-gb',
      'name':'en-GB-Standard-A',
      'ssmlGender':'FEMALE'
    },
    'audioConfig':{
      'audioEncoding':'MP3'
    }
  }"
"https://texttospeech.googleapis.com/v1/text:synthesize" > synthesize-text.txt


errors out at the first back slash like so:

C:\Users\Stefan.DESKTOP-QQLBN9D\AppData\Local\Google\Cloud SDK>curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
curl
: (6) Could not resolve host: auth
curl
: (6) Could not resolve host: application-default
curl
: (6) Could not resolve host: print-access-token)
curl
: (6) Could not resolve host: \


even after removing the backslashes
and all tab/spaces i still get the error like so:

C:\Users\Stefan.DESKTOP-QQLBN9D\AppData\Local\Google\Cloud SDK>curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) -H "Content-Type: application/json; charset=utf-8" --data "{'input':{'text':'Android is a mobile operating system developed by Google,based on the Linux kernel and designed primarily fortouchscreen mobile devices such as smartphones and tablets.'},'voice':{'languageCode':'en-gb','name':'en-GB-Standard-A','ssmlGender':'FEMALE'},'audioConfig':{'audioEncoding':'MP3'}}" "https://texttospeech.googleapis.com/v1/text:synthesize" > synthesize-text.txt
 
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 
Dload  Upload   Total   Spent    Left  Speed
 
0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0curl: (6) Could not resolve host: auth
 
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: application-default
 
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: print-access-token)
100   605    0   297  100   308    297    308  0:00:01 --:--:--  0:00:01   605



help?
curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
 
-H "Content-Type: application/json; charset=utf-8" \
 
--data "{
    'input':{
      'text':'Android is a mobile operating system developed by Google,
         based on the Linux kernel and designed primarily for
         touchscreen mobile devices such as smartphones and tablets.'
    },
    'voice':{
      'languageCode':'en-gb',
      'name':'en-GB-Standard-A',
      'ssmlGender':'FEMALE'
    },
    'audioConfig':{
      'audioEncoding':'MP3'
    }
  }"
"https://texttospeech.googleapis.com/v1/text:synthesize" > synthesize-text.txt
curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
 
-H "Content-Type: application/json; charset=utf-8" \
 
--data "{
    'input':{
      'text':'Android is a mobile operating system developed by Google,
         based on the Linux kernel and designed primarily for
         touchscreen mobile devices such as smartphones and tablets.'
    },
    'voice':{
      'languageCode':'en-gb',
      'name':'en-GB-Standard-A',
      'ssmlGender':'FEMALE'
    },
    'audioConfig':{
      'audioEncoding':'MP3'
    }
  }"
"https://texttospeech.googleapis.com/v1/text:synthesize" > synthesize-text.txt
curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
 
-H "Content-Type: application/json; charset=utf-8" \
 
--data "{
    'input':{
      'text':'Android is a mobile operating system developed by Google,
         based on the Linux kernel and designed primarily for
         touchscreen mobile devices such as smartphones and tablets.'
    },
    'voice':{
      'languageCode':'en-gb',
      'name':'en-GB-Standard-A',
      'ssmlGender':'FEMALE'
    },
    'audioConfig':{
      'audioEncoding':'MP3'
    }
  }"
"https://texttospeech.googleapis.com/v1/text:synthesize" > synthesize-text.txt

Jordan (Cloud Platform Support)

unread,
Oct 18, 2018, 1:16:46 PM10/18/18
to Google Cloud Developers
It looks as though the Windows commandline is having issues running the inner "$(gcloud auth application-default print-access-token)" command to populate the request with the default access token. 

Instead you may want to try running the command gcloud auth application-default print-access-token separately, then copy its output token and replace the entire "$(gcloud ..)" line for it. 

- Note that the tutorial was written to be run in a Linux shell, and not Windows. It is recommended to perform the steps within the Google Cloud Shell
Reply all
Reply to author
Forward
0 new messages