0

在一个 Angular 应用程序中,我设置了一个应用程序,该应用程序使用 Amazon Polly 主要基于this说出一些难以言说的东西。

我不得不像这样导入 Polly,因为我无法让 aws-sdk 允许导入 AWS,这曾经可以工作:

import { config, CognitoIdentityCredentials, Polly } from "aws-sdk";

我已经导入了@types/node,并且在tsconfig.app.json 文件的compilerOptions 下的types 下添加了["node']。

我在 polyfills.ts 中添加了以下内容:

(window as any).global = window;

对于我的一生,我无法弄清楚为什么下面的“polly”位会抛出一个错误,上面写着:“预期的参数为 0-1,但得到了 2。”

它阻止我部署构建。该怎么办?!

speakText() {
    const polly = new Polly();
    // I don't know why 'polly' is bitching about expectations.
    const signer = new Polly.Presigner(this.speechParams, polly);
4

1 回答 1

0

在添加 SpeechParams 和 polly 作为 Polly.Presigner 的选项时,我引用的文档似乎是不正确的。

删除这些选项消除了错误应用程序仍按预期工作。

  speakText() {
    const polly = new Polly({ apiVersion: "2016-06-10" });
    const signer = new Polly.Presigner();  // <== Removed options!

    signer.getSynthesizeSpeechUrl(
      this.speechParams,
      700,
      (error: Error, url: string) => {
        if (error) {
          console.log(error);
        } else {
          this.audio.src = url;
          this.audio.load();
        }
      }
    );
  }
于 2019-08-21T04:29:41.533 回答