Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java AWS StartSpeechsSynthesistaskrequest_Java_Amazon Web Services_Amazon S3_Aws Lambda_Amazon Polly - Fatal编程技术网

Java AWS StartSpeechsSynthesistaskrequest

Java AWS StartSpeechsSynthesistaskrequest,java,amazon-web-services,amazon-s3,aws-lambda,amazon-polly,Java,Amazon Web Services,Amazon S3,Aws Lambda,Amazon Polly,目前正在使用AWS服务通过使用Polly创建PCM音频文件并将其存储到S3存储桶中。应用程序正在使用AWS lambda完成所有这些工作 我使用的是“StartSpeechSynthesisTaskRequest”,它允许用户创建一个对amazon Polly的请求,并将文件直接传递到用户选择的指定S3存储桶中 我遇到的问题是,一旦代码运行完毕,我就会得到一个文件名,如下所示: “我的文件名。a1f9999f-f00r-6h45-j2ks-pd7fcc9sfw77.pcm” 我想要的是: “我的

目前正在使用AWS服务通过使用Polly创建PCM音频文件并将其存储到S3存储桶中。应用程序正在使用AWS lambda完成所有这些工作

我使用的是“StartSpeechSynthesisTaskRequest”,它允许用户创建一个对amazon Polly的请求,并将文件直接传递到用户选择的指定S3存储桶中

我遇到的问题是,一旦代码运行完毕,我就会得到一个文件名,如下所示:

“我的文件名。a1f9999f-f00r-6h45-j2ks-pd7fcc9sfw77.pcm”

我想要的是:

“我的文件名.pcm”

为什么会出现这种额外的情况?有人知道这个问题的答案吗

我已经把代码贴在下面了

StartSpeechSynthesisTaskRequest startSpeechSynthesisRequest = new StartSpeechSynthesisTaskRequest()
                        // Required parameters
                        .withOutputFormat(PCM_FORMAT)
                        .withOutputS3BucketName(s3BucketName) <--- S3 bucket location/name
                        .withText(GREETING_FORMAT)
                        .withVoiceId(EMMA_VOICE_ID)
                        // Optional parameters
                        .withOutputS3KeyPrefix("MY_FILE_NAME") <--- my file desired name
                        .withEngine(NEURAL_ENGINE)
                        .withLanguageCode(ENGB_LANGUAGE_CODE)
                        .withSampleRate(SAMPLE_RATE)
                        .withTextType(SSML_TEXT_TYPE);
                pollyClient.startSpeechSynthesisTask(startSpeechSynthesisRequest);
StartSpeechSynthesisTaskRequest startSpeechSynthesisRequest=新的StartSpeechSynthesisTaskRequest()
//所需参数
.无输出格式(PCM\U格式)

我不想这么说,但是你得到了你想要的。Polly的输出文件是requestId。您正在为S3对象请求一个前缀,它位于Polly对象的前面

如果我运行这个:

aws polly start-speech-synthesis-task \
--voice-id Joanna \
--output-format mp3 \
--output-s3-bucket-name BUCKET \
--text "This audio sample was created using Amazon Polly and the AWS Command Line Interface." \
--region us-west-2
回应是

{
    "SynthesisTask": {
        "TaskId": "020437c3-256f-4cd4-97d5-6785a8e477f4",
        "TaskStatus": "scheduled",
        "OutputUri": "https://s3.us-west-2.amazonaws.com/BUCKET/020437c3-256f-4cd4-97d5-6785a8e477f4.mp3",
        "CreationTime": 1584849572.835,
        "RequestCharacters": 84,
        "OutputFormat": "mp3",
        "TextType": "text",
        "VoiceId": "Joanna"
    }
}
注意输出URI——文件名是TaskId

如果我加上前缀


aws polly start-speech-synthesis-task \
--voice-id Joanna \
--output-format mp3 \
--output-s3-bucket-name BUCKET \
--output-s3-key-prefix MY_FILE_NAME \
--text "This audio sample was created using Amazon Polly and the AWS Command Line Interface." \
--region us-west-2
这就产生了反应

{
    "SynthesisTask": {
        "TaskId": "c887dc20-998e-47e3-9eaf-47db32aa2aa9",
        "TaskStatus": "scheduled",
        "OutputUri": "https://s3.us-west-2.amazonaws.com/BUCKET/MY_FILE_NAME.c887dc20-998e-47e3-9eaf-47db32aa2aa9.mp3",
        "CreationTime": 1584849928.825,
        "RequestCharacters": 84,
        "OutputFormat": "mp3",
        "TextType": "text",
        "VoiceId": "Joanna"
    }
}
这证实了你所看到的。因此,我的示例显示了使用CLI执行此操作,但S3KeyPrefix所做的只是将文本前置到Polly生成的文件名。没有定义实际文件名的方法

当您提交语音合成任务时,您应该捕获响应,它将告诉您TaskId,任务完成后,您知道TaskId将成为S3中的文件名。然后,您可以监视状态,完成后,将文件名更改为您想要的任何名称


HTH

我不想这么说,但你得到了你想要的。Polly的输出文件是requestId。您正在为S3对象请求一个前缀,它位于Polly对象的前面

如果我运行这个:

aws polly start-speech-synthesis-task \
--voice-id Joanna \
--output-format mp3 \
--output-s3-bucket-name BUCKET \
--text "This audio sample was created using Amazon Polly and the AWS Command Line Interface." \
--region us-west-2
回应是

{
    "SynthesisTask": {
        "TaskId": "020437c3-256f-4cd4-97d5-6785a8e477f4",
        "TaskStatus": "scheduled",
        "OutputUri": "https://s3.us-west-2.amazonaws.com/BUCKET/020437c3-256f-4cd4-97d5-6785a8e477f4.mp3",
        "CreationTime": 1584849572.835,
        "RequestCharacters": 84,
        "OutputFormat": "mp3",
        "TextType": "text",
        "VoiceId": "Joanna"
    }
}
注意输出URI——文件名是TaskId

如果我加上前缀


aws polly start-speech-synthesis-task \
--voice-id Joanna \
--output-format mp3 \
--output-s3-bucket-name BUCKET \
--output-s3-key-prefix MY_FILE_NAME \
--text "This audio sample was created using Amazon Polly and the AWS Command Line Interface." \
--region us-west-2
这就产生了反应

{
    "SynthesisTask": {
        "TaskId": "c887dc20-998e-47e3-9eaf-47db32aa2aa9",
        "TaskStatus": "scheduled",
        "OutputUri": "https://s3.us-west-2.amazonaws.com/BUCKET/MY_FILE_NAME.c887dc20-998e-47e3-9eaf-47db32aa2aa9.mp3",
        "CreationTime": 1584849928.825,
        "RequestCharacters": 84,
        "OutputFormat": "mp3",
        "TextType": "text",
        "VoiceId": "Joanna"
    }
}
这证实了你所看到的。因此,我的示例显示了使用CLI执行此操作,但S3KeyPrefix所做的只是将文本前置到Polly生成的文件名。没有定义实际文件名的方法

当您提交语音合成任务时,您应该捕获响应,它将告诉您TaskId,任务完成后,您知道TaskId将成为S3中的文件名。然后,您可以监视状态,完成后,将文件名更改为您想要的任何名称