aws sdk AWS Transcribe 卡在 iOS 中的 getTranscriptionJob 中



我正在尝试使用 aws-sdk-iOS 在 iOS 应用程序中使用 AWS Transcribe。该应用程序启动转录作业,我可以在 AWS 控制台上看到该作业。但是该应用程序无法列出作业或获取特定作业,因为它卡在请求中getTranscriptionJoblistTranscriptionJobs,因为这些请求永远不会完成(我在完成块中添加了一个 print 语句和一个断点,它永远不会打印,也不会到达断点(。

我向 GitHub 上传了一个演示该问题的示例单视图应用程序。您需要对 S3 和转录具有完全权限的 AWS 账户或 IAM 用户。将该账户的密钥和 S3 存储桶插入到相应变量中的ViewController.swift

https://github.com/joaomarceloods/AWSTranscribeBug

我需要帮助。这是一个错误,还是我做错了什么?

Swift, iOS 13.2, CocoaPods, AWSCore 2.12.1, AWSTranscribe 2.12.1

最重要的片段:

/// `getTranscriptionJob` repeatedly until the status is no longer `inProgress`.
/// However, `getTranscriptionJob` never completes.
var transcriptionInProgress = true
while transcriptionInProgress {
print("getTranscriptionJob")
transcribe.getTranscriptionJob(request).continueWith { task -> Any? in
print("getTranscriptionJob never completes...")
let transcriptionJob = task.result?.transcriptionJob
transcriptionInProgress = transcriptionJob?.transcriptionJobStatus == .inProgress
return nil
}.waitUntilFinished()
}
print("...after the getTranscriptionJob")

我找到了解决方案。

我仍然不明白为什么getTranscriptionJob冻结,但是如果您在DispatchQueue.global()上运行它,它将正常执行:

.continueWith(executor: AWSExecutor(dispatchQueue: DispatchQueue.global())) {

示例代码差异:https://github.com/joaomarceloods/AWSTranscribeBug/commit/98e43af553413ed2bbd0c3f96e259139a991303e

参考: https://aws-amplify.github.io/docs/ios/how-to-ios-asynchrounous-tasks#executing-a-block-on-the-main-thread-with-awstask

最新更新