首页 > 解决方案 > How do I use 'StartTranscriptionJobRequest' from the AWS Transcribe C++ API?

问题描述

I am having some difficulty with AWS Transcribe for C++. I believe a simple code example would solve it for me, but I find no code examples of the AWS Transcribe API in C++, (I realize there is one for TranscribeStreamingService, but my task is far simpler.)

According to the AWS docs for TranscribeServiceClient and StartTranscriptionJobRequest I need to create a StartTranscriptionJobRequest object, fill it in with setters, and hand it to the TranscribeServiceClient like this:

#include <aws/core/Aws.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/client/AWSClient.h>
#include <aws/transcribe/TranscribeServiceClient.h>

using namespace Aws;
using namespace Aws::TranscribeService;
using namespace Aws::TranscribeService::Model;

void TestAWSTranscript() {

    Aws::SDKOptions options;
    Aws::InitAPI(options);
    {
        Aws::Client::ClientConfiguration config;

        TranscribeServiceClient TranscriptClient(Auth::AWSCredentials(user_access_key.c_str(), user_private_key.c_str()), config);

        StartTranscriptionJobRequest request = new StartTranscriptionJobRequest();
        // request.SetLanguageCode(Aws::TranscribeService::Model::LanguageCode::en_US);
        // more setters here...

        TranscriptClient.StartTranscriptionJob(&request);
        // check for completion
        // enjoy transcript...

    }
    Aws::ShutdownAPI(options);
}

but the line:

StartTranscriptionJobRequest request = new StartTranscriptionJobRequest();

produces the errors:

Allocation of incomplete type 'Aws::TranscribeService::Model::StartTranscriptionJobRequest'
Variable has incomplete type 'Aws::TranscribeService::Model::StartTranscriptionJobRequest'

If it helps, the aws sdk is open-source and available on git.

What am I misunderstanding?

标签: c++amazon-web-servicesaws-transcribe

解决方案


incomplete type means the complete class definition is not available/the class is only forward declared.

adding
#include <aws/transcribe/model/StartTranscriptionJobRequest.h>
should fix this


推荐阅读