Skip to content

[google-cloud-java][Text-to-Speech][Android] want to use api key #3400

Description

@changemyminds

I use the Text-to-Speech Java Library on my Android app.
I want to use google cloud api-key to use the Text-to-Speech Java Library.

On my android. If I did the following code, it got the error message.

try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) { 
}

/* 
error message
java.io.IOException: The Application Default Credentials are not available. 
They are available if running in Google Compute Engine. 
Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials.
See https://developers.google.com/accounts/docs/application-default-credentials for more information.
*/

So I read the Authentication API Keys document and found API-Key not support Text-to-Speech, so I can't use api-key to Text-to-Speech Java Library.

If I want to use Text-to-Speech by API-Key or Text-to-Speech Java Library on Android. How can I do it ?

The following code is my command line and execute on mac and It work fine and can get the "audioContent". I think I can use http method by java. Is there any other way ?

Curl -H "X-Goog-Api-Key: API_KEY" \
  -H "Content-Type: application/json; charset=utf-8" \
  --data "{
    'input':{
      'text':'Hello I am david, Nice to meet you'
    },
    'voice':{
      'languageCode':'en-gb',
      'name':'en-GB-Standard-A',
      'ssmlGender':'FEMALE'
    },
    'audioConfig':{
      'audioEncoding':'MP3'
    }
  }" "https://texttospeech.googleapis.com/v1beta1/text:synthesize"

Activity

  1. changemyminds commented on Jun 24, 2018

    @changemyminds
    Author

    I use http-method to use the API_KEY on Android and it work fine for me.

    Here is the example. But if you use restricted Google API key on Android, it can't work.

    If the Text-to-Speech Java Library can support the API_KEY, please let me know. Thanks.

  2. added
    type: questionRequest for information or clarification. Not an issue.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    api: texttospeechIssues related to the Text-to-Speech API.
    and removed
    triage meI really want to be triaged.
    on Jun 26, 2018
  3. yihanzhen commented on Jun 27, 2018

    @yihanzhen
    Contributor

    Thanks for the information. Currently there probably won't be a better way, but we are working on an authentication approach for android right now. Please stand by.

  4. yankarinRG commented on Jul 7, 2019

    @yankarinRG

    Thanks for the information. Currently there probably won't be a better way, but we are working on an authentication approach for android right now. Please stand by.

    Hello @hzyi-google, since your reply is one year old, were there any updates on a dedicated Android library for Google Cloud Text-to-Speech?

    Thank you.

  5. IrfanJam33L commented on Aug 26, 2019

    @IrfanJam33L

    heyy can you provide full code? I want to use this API in my app but there is no proper documentation for using it in Android

  6. yihanzhen commented on Aug 26, 2019

    @yihanzhen
    Contributor

    I stopped working on the Java libraries a while ago so I don't know the latest status.

    cc/ @ajaaym @chingor13

  7. nikste commented on Jun 18, 2023

    @nikste

    Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

androidapi: texttospeechIssues related to the Text-to-Speech API.priority: p2Moderately-important priority. Fix may not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions