Что я пытаюсь сделать? Получить конкретный c фрагмент текста, выведенный из amazon Polly в формат mp3. это единственная функция AWS, которую я хочу реализовать в своем коде
Я пытался this (для amazon Polly), используя свои учетные данные пользователя с доступом к amazon Polly
Мой код:
android Студия не может разрешить AmazonPollyClientBuilder или AWSClientBuilder. Я не знаю почему, потому что у меня есть все импорты и зависимости.
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;
import java.net.URL;
import java.util.List;
public class AmazonPolly {
public URL getAudioStream(String name) {
BasicAWSCredentials awsCred = new BasicAWSCredentials("accessKeyId","SecretAccessKey");
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("this is the audio for "+ 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;
}
мой уровень проекта build.gradle:
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"
}
мой модуль: уровень приложения build.gradle:
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'
}