awsdocs / amazon-polly-developer-guide

The open source version of the Amazon Polly docs. You can submit feedback & requests for changes by submitting issues in this repo or by making proposed changes & submitting a pull request.
Other
31 stars 37 forks source link

Android Studio cannot resolve 'AmazonPollyClientBuilder' or 'AWSClientBuilder'. everything else seems wroking #9

Closed aI3hinandan closed 3 years ago

aI3hinandan commented 4 years ago

What i'm trying to do?

Get a specific piece of text outputted from amazon polly to mp3 format. i tried following the amazon aws android example in the polly guide. that crashed my app with a null point exception

i tried following the java example but it shows me that AmazonPollyClient constructor is deprecated.

i then tried this:

https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html

My Code : `import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.regions.Regions; import com.amazonaws.services.polly.AmazonPollyClient; import com.amazonaws.services.polly.model.DescribeVoicesRequest; import com.amazonaws.services.polly.model.DescribeVoicesResult; import com.amazonaws.services.polly.model.OutputFormat; import com.amazonaws.services.polly.model.SynthesizeSpeechPresignRequest; import com.amazonaws.services.polly.model.Voice;

public class AmazonPolly {

public URL getRingtones(String name) {
    BasicAWSCredentials awsCred = new BasicAWSCredentials("XXXXXXXXXXX","XXXXXXXXXX");
    AmazonPollyClient client = AmazonPollyClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCred)).build();
    DescribeVoicesRequest describeVoicesRequest = new DescribeVoicesRequest();

    // voice options
    DescribeVoicesResult describeVoicesResult = client.describeVoices(describeVoicesRequest);
    List<Voice> voices = describeVoicesResult.getVoices();
    SynthesizeSpeechPresignRequest synthesizeSpeechPresignRequest =
            new SynthesizeSpeechPresignRequest()
                    // Set text
                    .withText("You have a call from " + name + "   ")
                    // Set voice
                    .withVoiceId(voices.get(0).getId()) // "Joanna"
                    // Set format
                    .withOutputFormat(OutputFormat.Mp3);

// Get the presigned URL for synthesized speech audio stream. URL presignedSynthesizeSpeechUrl = client.getPresignedSynthesizeSpeechUrl(synthesizeSpeechPresignRequest); return presignedSynthesizeSpeechUrl;

}

My dependencies in build.gradle: module: app > dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.amazonaws:aws-android-sdk-polly:2.15.2' implementation ('com.amazonaws:aws-android-sdk-mobile-client:2.6.23@aar') { transitive = true } implementation group: 'com.amazonaws', name: 'aws-android-sdk-core', version: '2.15.2' implementation ('com.amazonaws:aws-android-sdk-auth-core:2.15.+@aar') { transitive = true } implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.core:core-ktx:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' }`

my dependencies in build.gradle( project level) > dependencies { classpath 'com.android.tools.build:gradle:3.6.1' classpath 'com.amazonaws:aws-android-sdk-appsync-gradle-plugin:2.9.+' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }

aI3hinandan commented 3 years ago

Never resolved. Switched to the rest api